initphp/cli-table

This package is abandoned and no longer maintained. The author suggests using the initphp/console package instead.

PHP CLI Table Generator (DEPRECATED — merged into initphp/console:^2.1)

Maintainers

Package info

github.com/InitPHP/CLITable

pkg:composer/initphp/cli-table

Statistics

Installs: 1 768

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

1.0.1 2026-05-24 09:21 UTC

This package is auto-updated.

Last update: 2026-05-24 09:21:51 UTC


README

⚠️ DEPRECATED — Use initphp/console instead

As part of the InitPHP package consolidation, this package has been merged into initphp/console starting with version 2.1. The consolidated package ships an identical table renderer under \InitPHP\Console\Utils\Table plus the rest of the Console toolkit (Application, Command, Input, Output, Question).

This repository is kept read-only for historical reference. No further updates will be released.

Migration

  1. Update your composer.json:

    - "initphp/cli-table": "^1.0",
    + "initphp/console": "^2.1"
  2. Your existing use InitPHP\CLITable\Table; imports keep working — initphp/console:^2.1 ships a class_alias that aliases the old FQCN to the canonical \InitPHP\Console\Utils\Table. No source changes required.

  3. When you next touch the code, prefer the new canonical namespace:

    // Before
    use InitPHP\CLITable\Table;
    
    // After
    use InitPHP\Console\Utils\Table;

Composer declares a replace from initphp/console:^2.1 to this package, so the two will not be installed side-by-side.

This library allows you to create nice looking tables in the CLI interface with PHP.

Note : Not required, but the MB_String extension is highly recommended.

Installation

composer require initphp/cli-table

or include src/Table.php.

Usage

<?php
require_once __DIR__ . "/vendor/autoload.php";
use \InitPHP\CLITable\Table;

$table = new Table();

$table->row([
    'id'        => 1,
    'name'      => 'Matthew S.',
    'surname'   => 'Kramer',
    'email'     => 'matthew@example.com',
    'status'    => true,
]);

$table->row([
    'id'        => 2,
    'name'      => 'Millie J.',
    'surname'   => 'Koenig',
    'email'     => 'millie@example.com',
    'status'    => false,
]);

$table->row([
    'id'        => 3,
    'name'      => 'Regina G.',
    'surname'   => 'Hart',
    'email'     => 'regina@example.com',
    'status'    => true,
]);

echo $table;

Output :

basic-cli-table

Styled

<?php
declare(strict_types=1);
require_once __DIR__ . '/../vendor/autoload.php';
use InitPHP\CLITable\Table;

$table = new Table();
$table->setBorderStyle(Table::COLOR_BLUE);
$table->setCellStyle(Table::COLOR_GREEN);
$table->setHeaderStyle(Table::COLOR_RED, Table::BOLD);

$table->setColumnCellStyle('id', Table::ITALIC, Table::COLOR_LIGHT_YELLOW);
$table->setColumnCellStyle('email', Table::BOLD, Table::ITALIC);

$table->row([
    'id'        => 1,
    'name'      => 'Matthew S.',
    'surname'   => 'Kramer',
    'email'     => 'matthew@example.com',
    'status'    => true,
]);

$table->row([
    'id'        => 2,
    'name'      => 'Millie J.',
    'surname'   => 'Koenig',
    'email'     => 'millie@example.com',
    'status'    => false,
]);

$table->row([
    'id'        => 3,
    'name'      => 'Regina G.',
    'surname'   => 'Hart',
    'email'     => 'regina@example.com',
    'status'    => true,
]);

echo $table;

Output :

styled-cli-table

Credits

License

Copyright © 2022 MIT License