Ncurses wrapper for fast TUI building

v0.4.7 2019-06-07 11:07 UTC

This package is auto-updated.

Last update: 2021-03-17 11:30:58 UTC


⚡ Habarnam

Warning! ⚠️

This package is in early development, so don't use it until you know your risks.

Framework/wrapper for ext-ncurses that will allows you to write simple CLI applications using a little bit of XML and PHP.

Give a ⭐ if like it and write me if you don't and we will make it better.

Made with habarnam:

Soon could be implemented:

  • Chat (WIP)
  • Redis or MySQL browser
  • Reddit browser
  • Ascii drawing tool

If you have some ideas, then create an issue and we will discuss it 🤘


#go to you project directory and require it into your project
composer require aharabara/habarnam

# then install ext-ncurses with its patches, so it will work for php 7.*
# and add 'extension=ncurses.so' to your php.ini

touch ./index.php
mkdir ./src/
mkdir ./logs/
mkdir ./views/
mkdir ./assets/
touch ./views/surfaces.xml
touch ./views/main.xml
touch ./assets/styles.css

index.php content


use Base\{Application, Core\Installer, Core\Workspace, Services\ViewRender};

require __DIR__ . '/vendor/autoload.php';

$projectName = '<You project name>'; // will be used to create a folder inside ~/.config
$workspace = new Workspace("habarnam-{$projectName}");
$installer = new Installer($workspace);


if (!$installer->isInstalled()) {

/* folder with surfaces.xml and other view files */
$render = new ViewRender(__DIR__. '/views/');

(new Application($workspace, $render->prepare(), 'main'))

surface.xml content

    <!-- each surface should be declared inside application>surfaces element
         and should have 'id' attribute
    <surface id="example.middle">
        <!-- top left corner of the surface-->
        <pos x="10" y="4"/>
        <!-- top bottom corner of the surface-->
        <pos x="-10" y="8"/>

        <!-- y="-5"  will lead to calculation from bottom and not from the top -->
        <!-- x="-5"  will lead to calculation from right and not from the left -->
    <surface id="example.fullscreen"/>
    <!-- In some cases you just need a popup, so you can use [type=centered]
         and specify it's [height] and [width]
    <surface id="example.popup" height="7" type="centered"/>

main.xml content

<template id="main"> <!-- template tag represents a screen with components -->
    <!-- you can jump between view using Application->switchTo('TemplateID') or BaseController->switchTo('TemplateID')-->
        <!-- you can specify here which css files you want to load for this template-->
        <link src="/assets/styles.css"/> 
        <section title="Users" surface="column.left"> <!-- surface attribute will set section size and position -->
            <ol id="users" on.item.selected="\App\UserController@login"> <!-- on.* are events that are triggered during interaction -->
                <li value="user-1">User</li> <!-- you can nest some components, for example ol > li -->
        <section title="History" surface="column.right.top"> <!-- or section > * -->
            <textarea id="info"/>
        <section title="Message" surface="column.right.bottom">
            <input id="message"/> <!-- you can address any (non-dynamic) component via Application->findFirst('.css>selector')-->
            <button on.press="\App\UserController@login" id="send">Send</button> <!-- or via Application->findAll('selector')-->


  • To navigate through components use Tab and Shift + Tab or keyboard arrows.
  • Call Application->debug(true) and then press F1 and you will be able to see components surfaces. Surface calculation is still glitchy, but you can use it.
  • Press F3 to toggle resize mode
  • Press F5 to refresh styles from css files. (🆒)
  • Press Ctrl+X to exit application. Be careful and save everything before doing it.
  • more coming...