|
1 | | -# CLITable |
2 | | -PHP CLI Table |
| 1 | +# InitPHP CLI Table Generator |
| 2 | + |
| 3 | +This library allows you to create nice looking tables in the CLI interface with PHP. |
| 4 | + |
| 5 | +_**Note** : Not required, but the **MB_String** extension is highly recommended._ |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +``` |
| 10 | +composer require initphp/cli-table |
| 11 | +``` |
| 12 | + |
| 13 | +or include `src/Table.php`. |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +```php |
| 18 | +<?php |
| 19 | +require_once __DIR__ . "/vendor/autoload.php"; |
| 20 | +use \InitPHP\CLITable\Table; |
| 21 | + |
| 22 | +$table = new Table(); |
| 23 | + |
| 24 | +$table->row([ |
| 25 | + 'id' => 1, |
| 26 | + 'name' => 'Matthew S.', |
| 27 | + 'surname' => 'Kramer', |
| 28 | + |
| 29 | + 'status' => true, |
| 30 | +]); |
| 31 | + |
| 32 | +$table->row([ |
| 33 | + 'id' => 2, |
| 34 | + 'name' => 'Millie J.', |
| 35 | + 'surname' => 'Koenig', |
| 36 | + |
| 37 | + 'status' => false, |
| 38 | +]); |
| 39 | + |
| 40 | +$table->row([ |
| 41 | + 'id' => 3, |
| 42 | + 'name' => 'Regina G.', |
| 43 | + 'surname' => 'Hart', |
| 44 | + |
| 45 | + 'status' => true, |
| 46 | +]); |
| 47 | + |
| 48 | +echo $table; |
| 49 | +``` |
| 50 | + |
| 51 | +Output : |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +### Styled |
| 56 | + |
| 57 | +```php |
| 58 | +<?php |
| 59 | +declare(strict_types=1); |
| 60 | +require_once __DIR__ . '/../vendor/autoload.php'; |
| 61 | +use InitPHP\CLITable\Table; |
| 62 | + |
| 63 | +$table = new Table(); |
| 64 | +$table->setBorderStyle(Table::COLOR_BLUE); |
| 65 | +$table->setCellStyle(Table::COLOR_GREEN); |
| 66 | +$table->setHeaderStyle(Table::COLOR_RED, Table::BOLD); |
| 67 | + |
| 68 | +$table->setColumnCellStyle('id', Table::ITALIC, Table::COLOR_LIGHT_YELLOW); |
| 69 | +$table->setColumnCellStyle('email', Table::BOLD, Table::ITALIC); |
| 70 | + |
| 71 | +$table->row([ |
| 72 | + 'id' => 1, |
| 73 | + 'name' => 'Matthew S.', |
| 74 | + 'surname' => 'Kramer', |
| 75 | + |
| 76 | + 'status' => true, |
| 77 | +]); |
| 78 | + |
| 79 | +$table->row([ |
| 80 | + 'id' => 2, |
| 81 | + 'name' => 'Millie J.', |
| 82 | + 'surname' => 'Koenig', |
| 83 | + |
| 84 | + 'status' => false, |
| 85 | +]); |
| 86 | + |
| 87 | +$table->row([ |
| 88 | + 'id' => 3, |
| 89 | + 'name' => 'Regina G.', |
| 90 | + 'surname' => 'Hart', |
| 91 | + |
| 92 | + 'status' => true, |
| 93 | +]); |
| 94 | + |
| 95 | +echo $table; |
| 96 | +``` |
| 97 | + |
| 98 | +Output : |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | +## Credits |
| 104 | + |
| 105 | +- [Muhammet ŞAFAK ](https://github.com/muhammetsafak) < <[email protected]>> |
| 106 | + |
| 107 | +## License |
| 108 | + |
| 109 | +Copyright © 2022 [MIT License](./LICENSE) |
0 commit comments