PHPackages                             phplucidframe/console-table - 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. phplucidframe/console-table

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

phplucidframe/console-table
===========================

Console Table

v1.4.0(11mo ago)102637.3k↓11.1%25[2 issues](https://github.com/phplucidframe/console-table/issues)20MITPHPPHP &gt;=7.1CI failing

Since Sep 22Pushed 11mo ago3 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (12)Used By (20)

PHP ConsoleTable
================

[](#php-consoletable)

**ConsoleTabe** makes you easy to build console style tables. It helps you to display tabular data in terminal/shell. This is a component of [PHPLucidFrame](https://github.com/phplucidframe/phplucidframe).

License: [MIT](https://opensource.org/licenses/MIT)

Composer Installation
---------------------

[](#composer-installation)

```
composer require phplucidframe/console-table

```

Example 1: Bordered Table (Default)
-----------------------------------

[](#example-1-bordered-table-default)

```
$table = new LucidFrame\Console\ConsoleTable();
$table
    ->addHeader('Language')
    ->addHeader('Year')
    ->addRow()
        ->addColumn('PHP')
        ->addColumn(1994)
    ->addRow()
        ->addColumn('C++')
        ->addColumn(1983)
    ->addRow()
        ->addColumn('C')
        ->addColumn(1970)
    ->display()
;

```

You can also print the table using `getTable` method such as `echo $table->getTable();`

**Output**:

```
+----------+------+
| Language | Year |
+----------+------+
| PHP      | 1994 |
| C++      | 1983 |
| C        | 1970 |
+----------+------+

```

Example 2: Bordered Table with Padding Width 2
----------------------------------------------

[](#example-2-bordered-table-with-padding-width-2)

You can also use `setHeaders()` and `addRow` with Arrays.

```
$table = new LucidFrame\Console\ConsoleTable();
$table
    ->setHeaders(array('Language', 'Year'))
    ->addRow(array('PHP', 1994))
    ->addRow(array('C++', 1983))
    ->addRow(array('C', 1970))
    ->setPadding(2)
    ->display()
;

```

**Output**:

```
+------------+--------+
|  Language  |  Year  |
+------------+--------+
|  PHP       |  1994  |
|  C++       |  1983  |
|  C         |  1970  |
+------------+--------+

```

Example 3: Bordered Table with Left Margin Width 4
--------------------------------------------------

[](#example-3-bordered-table-with-left-margin-width-4)

```
$table = new LucidFrame\Console\ConsoleTable();
$table
    ->setHeaders(array('Language', 'Year'))
    ->addRow(array('PHP', 1994))
    ->addRow(array('C++', 1983))
    ->addRow(array('C', 1970))
    ->setIndent(4)
    ->display()
;

```

**Output**:

```
    +----------+------+
    | Language | Year |
    +----------+------+
    | PHP      | 1994 |
    | C++      | 1983 |
    | C        | 1970 |
    +----------+------+

```

Example 4: Non-bordered Table with Header
-----------------------------------------

[](#example-4-non-bordered-table-with-header)

```
$table = new LucidFrame\Console\ConsoleTable();
$table
    ->setHeaders(array('Language', 'Year'))
    ->addRow(array('PHP', 1994))
    ->addRow(array('C++', 1983))
    ->addRow(array('C', 1970))
    ->hideBorder()
    ->display()
;

```

**Output**:

```
 Language  Year
----------------
 PHP       1994
 C++       1983
 C         1970

```

Example 5: Non-bordered Table without Header
--------------------------------------------

[](#example-5-non-bordered-table-without-header)

```
$table = new LucidFrame\Console\ConsoleTable();
$table
    ->addRow(array('PHP', 1994))
    ->addRow(array('C++', 1983))
    ->addRow(array('C', 1970))
    ->hideBorder()
    ->display()
;

```

**Output**:

```
 PHP  1994
 C++  1983
 C    1970

```

Example 6: Table with all borders
---------------------------------

[](#example-6-table-with-all-borders)

```
$table = new LucidFrame\Console\ConsoleTable();
$table
    ->setHeaders(array('Language', 'Year'))
    ->addRow(array('PHP', 1994))
    ->addRow(array('C++', 1983))
    ->addRow(array('C', 1970))
    ->showAllBorders()
    ->display()
;

```

Alternatively, you can use `addBorderLine()` for each row.

```
$table
    ->setHeaders(array('Language', 'Year'))
    ->addRow(array('PHP', 1994))
    ->addBorderLine()
    ->addRow(array('C++', 1983))
    ->addBorderLine()
    ->addRow(array('C', 1970))
    ->display()
;

```

**Output**

```
+----------+------+
| Language | Year |
+----------+------+
| PHP      | 1994 |
+----------+------+
| C++      | 1983 |
+----------+------+
| C        | 1970 |
+----------+------+

```

Example 7: Table with Column Alignment
--------------------------------------

[](#example-7-table-with-column-alignment)

```
$table = new LucidFrame\Console\ConsoleTable();
$table
    ->addHeader('A')
    ->addHeader('B', ConsoleTable::ALIGN_RIGHT) # ALIGN_LEFT or ALIGN_RIGHT (ALIGN_LEFT is default)
    ->addHeader('C')
    ->addRow()
        ->addColumn('X')
        ->addColumn('Hello', null, null, ConsoleTable::ALIGN_RIGHT)
        ->addColumn('Nice')
    ->addRow()
        ->addColumn('Y')
        ->addColumn('Hello, how are you?')
        ->addColumn('OK', null, null, ConsoleTable::ALIGN_RIGHT)
    ->display();

```

**Output**

```
+---+---------------------+------+
| A |                   B | C    |
+---+---------------------+------+
| X |               Hello | Nice |
| Y | Hello, how are you? |   OK |
+---+---------------------+------+

```

Example 8: Bordered Table with Header &amp; Footer
==================================================

[](#example-8-bordered-table-with-header--footer)

```
$table = new LucidFrame\Console\ConsoleTable();
$table
    ->addHeader('Name')
    ->addHeader('Age')
    ->addRow()
        ->addColumn('John')
        ->addColumn(25, null, null, ConsoleTable::ALIGN_RIGHT)
    ->addRow()
        ->addColumn('Jane')
        ->addColumn(23, null, null, ConsoleTable::ALIGN_RIGHT)
    ->addFooter('Total')
    ->addFooter('48', ConsoleTable::ALIGN_RIGHT)
    ->display();

```

**Output**

```
+-------+-----+
| Name  | Age |
+-------+-----+
| John  |  25 |
| Jane  |  23 |
+-------+-----+
| Total |  48 |
+-------+-----+

```

Example 9: Non-bordered Table with Header &amp; Footer
======================================================

[](#example-9-non-bordered-table-with-header--footer)

```
$table = new LucidFrame\Console\ConsoleTable();
$table
    ->setHeaders(array('Name', 'Age'))
    ->addRow(array('John', 25))
    ->addRow(array('Jane', 23))
    ->setFooters(array('Total', 48))
    ->hideBorder()
    ->display();

```

**Output**

```
Name   Age
-----------
John   25
Jane   23
-----------
Total  48

```

Test
----

[](#test)

With PHPUnit, you can run this in your terminal.

```
composer install
vendor\bin\phpunit tests

```

Without PHPUnit, you can simply run this in your terminal.

```
php example.php

```

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance50

Moderate activity, may be stable

Popularity54

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 78.9% 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 ~352 days

Recently: every ~597 days

Total

10

Last Release

356d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.3

v1.3.1PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/1978d5b9794474fb6a215f25e84c060a342318cfe9bdb3bdbdadd3f373b15b5a?d=identicon)[cithukyaw](/maintainers/cithukyaw)

---

Top Contributors

[![cithukyaw](https://avatars.githubusercontent.com/u/4285555?v=4)](https://github.com/cithukyaw "cithukyaw (30 commits)")[![pitsolu](https://avatars.githubusercontent.com/u/16669704?v=4)](https://github.com/pitsolu "pitsolu (4 commits)")[![matteoporru](https://avatars.githubusercontent.com/u/34092391?v=4)](https://github.com/matteoporru "matteoporru (2 commits)")[![dblencowe](https://avatars.githubusercontent.com/u/88084?v=4)](https://github.com/dblencowe "dblencowe (1 commits)")[![i-amdroid](https://avatars.githubusercontent.com/u/4057077?v=4)](https://github.com/i-amdroid "i-amdroid (1 commits)")

---

Tags

console-toolphpphp-frameworkphp-libraryphplucidframe

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)
