Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

InitPHP/CLITable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

2 Commits

Repository files navigation

InitPHP CLI Table Generator

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /