PHPackages                             lucinda/console - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. lucinda/console

ActiveLibrary[CLI &amp; Console](/categories/cli)

lucinda/console
===============

Lucinda Console Table: API able to draw tables in UNIX consoles or windows command prompt

v2.0.5(3y ago)220.6k↑75%12MITPHPPHP ^8.1

Since Feb 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/aherne/console)[ Packagist](https://packagist.org/packages/lucinda/console)[ RSS](/packages/lucinda-console/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (17)Used By (2)

Lucinda Console
===============

[](#lucinda-console)

This API was created to give an ability of styling console responses so they are easy to read and pleasurable to see. It does this in two steps:

1. Defining a platform to create and format texts via following classes:
    - **[Text](#Text)**: class encapsulating a text, able to be applied any of above three UNIX styling options:
        - **[BackgroundColor](https://github.com/aherne/console/blob/master/src/BackgroundColor.php)**: enum encapsulating background colors UNIX console texts can have
        - **[ForegroundColor](https://github.com/aherne/console/blob/master/src/ForegroundColor.php)**: enum encapsulating foreground colors UNIX console texts can have
        - **[FontStyle](https://github.com/aherne/console/blob/master/src/FontStyle.php)**: enum encapsulating font styles UNIX console texts can have (eg: bold)
    - **[Table](#Table)**: class encapsulating a table, not able to include sub-tables
    - **[OrderedList](#OrderedList)**: class encapsulating an ordered list, able to contain leaves that point to other ordered lists
    - **[UnorderedList](#UnorderedList)**: class encapsulating a unordered list, able to contain leaves that point to other unordered lists
2. Defining a HTML-like [templating language](#console-templating-language) that points to above structures behind the scenes, helping developers to implement console frontend without programming via following tags:
    - **[&lt;div&gt;](#div-tag)**: same as HTML tag but only supporting *style* attribute.
    - **[&lt;table&gt;](#table-tag)**: same as HTML tag but with a number of restrictions
    - **[&lt;ol&gt;](#ol-tag)**: same as HTML tag but with a number of differences and restrictions
    - **[&lt;ul&gt;](#ul-tag)**: same as HTML tag, with equivalent differences and restrictions as &lt;ol&gt;
    - **[&lt;span&gt;](#span-tag)**: same as HTML tag
    - **[&lt;u&gt;](#u-tag)**: same as HTML tag
    - **[&lt;b&gt;](#b-tag)**: same as HTML tag
    - **[&lt;i&gt;](#i-tag)**: same as HTML tag
3. Defining a class able to bind templated text at point #2 with structures at point #3 in order to build the final view:
    - **[Wrapper](#Wrapper)**: class encapsulating a table

API requires no dependency other than PHP 8.1+ interpreter and SimpleXML extension. All classes inside belong to **Lucinda\\Console** interface!

Example Usage
-------------

[](#example-usage)

```
// defines text to be compiled
$text = '
hello

            Name
            Value

            qqq
            sss

            ddd
            fff

    Is Lucinda smart?

            Yes
            qwerty
            asdfgh

    No

';

// compiling and outputting results (on windows style attributes will be ignored)
$wrapper = new Lucinda\Console\Wrapper($text);
echo $wrapper->getBody();
```

Console Templating Language
---------------------------

[](#console-templating-language)

Console templating language supports a fraction of HTML standard, namely parts that are feasable in styling and formatting console text. Certain elements allow a *style* attribute that supports following CSS directives:

- *font-style*: value must be one of [FontStyle](https://github.com/aherne/console/blob/master/src/FontStyle.php) constant names
- *background-color*: value must be one of [BackgroundColor](https://github.com/aherne/console/blob/master/src/BackgroundColor.php) constant names
- *color*: value must be one of [ForegroundColor](https://github.com/aherne/console/blob/master/src/ForegroundColor.php) constant names

### Div Tag

[](#div-tag)

Binding to **[Text](#Text)**, works the same as HTML &lt;div&gt; tag with following restrictions:

- only supporting *style* attribute
- body can only contain plain text or/and [&lt;span&gt;](#span-tag), [&lt;u&gt;](#u-tag), [&lt;b&gt;](#b-tag), [&lt;i&gt;](#i-tag) tags

Syntax example:

```
Hello, world!
```

### Table Tag

[](#table-tag)

Binding to **[Table](#Table)**, works the same as HTML &lt;table&gt; tag with following restrictions:

- must have a &lt;thead&gt; child
- must have a &lt;tbody&gt; child
- any &lt;tr&gt; inside supports no attributes
- any &lt;td&gt; inside supports only *style* attribute
- any &lt;td&gt; body can only contain plain text

Syntax example:

```

            Name
            Value

            qqq
            sss

```

### Ol Tag

[](#ol-tag)

Binding to **[OrderedList](#OrderedList)**, works the same as HTML &lt;ol&gt; tag with following differences and restrictions:

- can contain a &lt;caption&gt; tag defining what list is about (behaving as **[&lt;div&gt;](#div-tag)**).
- if a &lt;caption&gt; is present it MUST be first child!
- must contain &lt;li&gt; sub-tags supporting only *style* attribute
- any &lt;li&gt; body can only contain one of below:
    - plain text or/and [&lt;span&gt;](#span-tag), [&lt;u&gt;](#u-tag), [&lt;b&gt;](#b-tag), [&lt;i&gt;](#i-tag) tags
    - another &lt;ol&gt;/&lt;ul&gt; tag

Example:

```

    Is Lucinda smart?

            Yes
            qwerty
            asdfgh

    No

```

### Ul Tag

[](#ul-tag)

Binding to **[UnorderedList](#UnorderedList)**, works the same as HTML &lt;ul&gt; tag with equivalent differences and restrictions as **[&lt;ol&gt;](#ol-tag)**.

### Span Tag

[](#span-tag)

Works the same as HTML &lt;span&gt; with following restrictions:

- supports only *style* attribute
- plain text or/and [&lt;u&gt;](#u-tag), [&lt;b&gt;](#b-tag), [&lt;i&gt;](#i-tag) tags
- can only occur inside a [&lt;div&gt;](#div-tag) or &lt;caption&gt;

Example:

```
Hello, Lucian!
```

### B Tag

[](#b-tag)

Works the same as HTML &lt;b&gt; with same restrictions as [&lt;span&gt;](#span-tag) tag! Equivalent to:

```
Lucian
```

### U Tag

[](#u-tag)

Works the same as HTML &lt;u&gt; with same restrictions as [&lt;span&gt;](#span-tag) tag! Equivalent to:

```
Lucian
```

^ Note the difference from HTML *text-decoration: underline*

### I Tag

[](#i-tag)

Works the same as HTML &lt;i&gt; with same restrictions as [&lt;span&gt;](#span-tag) tag! Equivalent to:

```
Lucian
```

^ Note the difference from HTML *font-style: italic*

Reference Guide
---------------

[](#reference-guide)

### Text

[](#text)

Class [Lucinda\\Console\\Text](https://github.com/aherne/console/blob/master/src/Text.php) implements [Stringable](https://www.php.net/manual/en/class.stringable.php) and styles a UNIX console text, defining following public methods:

MethodArgumentsReturnsDescription\_\_constructstring $textvoidSets text to stylesetFontStyle[Lucinda\\Console\\FontStyle](https://github.com/aherne/console/blob/master/src/FontStyle.php) $stylevoidSets text style (eg: makes it bold) from input enum member.setBackgroundColor[Lucinda\\Console\\BackgroundColor](https://github.com/aherne/console/blob/master/src/BackgroundColor.php) $colorvoidSets text background color from input enum member.setForegroundColor[Lucinda\\Console\\ForegroundColor](https://github.com/aherne/console/blob/master/src/ForegroundColor.php) $colorvoidSets text foreground color from input enum member.getOriginalValuevoidstringGets original text before stylinggetStyledValuevoidstringGets final text after stylingtoStringvoidstringGets final string representation of text to be shown on console/terminal### Table

[](#table)

Class [Lucinda\\Console\\Table](https://github.com/aherne/console/blob/master/src/Table.php) implements [Stringable](https://www.php.net/manual/en/class.stringable.php) and creates a table to be displayed on console/terminal, defining following public methods:

MethodArgumentsReturnsDescription\_\_constructarray $columnsvoidSets table columns based on *string* or *[Text](#Text)* array inputaddRowarray $rowvoidAdds a row to table based on *string* or *[Text](#Text)* array inputtoStringvoidstringGets final string representation of table to be shown on console/terminal### AbstractList

[](#abstractlist)

Abstract class [Lucinda\\Console\\AbstractList](https://github.com/aherne/console/blob/master/src/AbstractList.php) implements [Stringable](https://www.php.net/manual/en/class.stringable.php) and creates a list to be displayed on console/terminal, defining following public methods:

MethodArgumentsReturnsDescription\_\_constructint $indent = 0voidConstructs a list by number of spaces to indent in members (default=5)setCaptionstring|Text $captionvoidSets optional caption to define what list is about based on *string* or *[Text](#Text)* inputaddItemstring|Text $itemvoidAdds a textual member to list based on *string* or *[Text](#Text)* input.addList[AbstractList](#AbstractList)voidAdds a [AbstractList](#AbstractList) member to listtoStringvoidstringGets final string representation of list to be shown on console/terminaland following abstract method children must implement:

MethodArgumentsReturnsDescriptionformatOptionNumberint $optionNumberstringFormats list option number for later display### OrderedList

[](#orderedlist)

Class [Lucinda\\Console\\OrderedList](https://github.com/aherne/console/blob/master/src/OrderedList.php) extends [AbstractList](#AbstractList) and creates an ordered list to be displayed on console/terminal.

### UnorderedList

[](#unorderedlist)

Class [Lucinda\\Console\\UnorderedList](https://github.com/aherne/console/blob/master/src/UnorderedList.php) extends [AbstractList](#AbstractList) and creates an uordered list to be displayed on console/terminal.

### Wrapper

[](#wrapper)

Class [Lucinda\\Console\\Wrapper](https://github.com/aherne/console/blob/master/src/Wrapper.php) compiles user-defined text using [Console Templating Language](#console-templating-language) by binding tags inside to their equivalent classes. It defines following public methods:

MethodArgumentsReturnsDescription\_\_constructstring $bodyvoidTakes text received and compiles itgetBodyvoidstringGets compiled body, ready to be displayed on console/terminalIf compilation fails, a [Lucinda\\Console\\Exception](https://github.com/aherne/console/blob/master/src/Exception.php) is thrown!

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~45 days

Recently: every ~87 days

Total

16

Last Release

1240d ago

Major Versions

v1.2.1 → v2.0.02021-12-28

v1.2.2 → v2.0.12021-12-28

v1.0.x-dev → v2.0.32022-01-09

PHP version history (3 changes)v1.0.0PHP ^7.1

v2.0.0PHP ^8.1

v1.2.3PHP ^7.1|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3382770?v=4)[Lucian Gabriel Popescu](/maintainers/aherne)[@aherne](https://github.com/aherne)

---

Top Contributors

[![aherne](https://avatars.githubusercontent.com/u/3382770?v=4)](https://github.com/aherne "aherne (22 commits)")

---

Tags

consoletemplatingterminaltablesunix consolecommand prompt

### Embed Badge

![Health badge](/badges/lucinda-console/health.svg)

```
[![Health](https://phpackages.com/badges/lucinda-console/health.svg)](https://phpackages.com/packages/lucinda-console)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.1k17.2M320](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M19](/packages/consolidation-annotated-command)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)[codedungeon/php-cli-colors

Liven up you PHP Console Apps with standard colors

10210.1M26](/packages/codedungeon-php-cli-colors)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
