Skip to content

Commit ef577a4

Browse files
committed
First commit
1 parent 8b3eaec commit ef577a4

File tree

7 files changed

+493
-2
lines changed

7 files changed

+493
-2
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Examples/ export-ignore

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.idea/
2+
/.vscode/
3+
/.vs/
4+
/vendor/
5+
/composer.lock

Examples/basic.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!usr/bin/php
2+
<?php
3+
declare(strict_types=1);
4+
require_once __DIR__ . '/../vendor/autoload.php';
5+
use InitPHP\CLITable\Table;
6+
7+
$table = new Table();
8+
9+
$table->row([
10+
'id' => 1,
11+
'name' => 'Matthew S.',
12+
'surname' => 'Kramer',
13+
'email' => '[email protected]',
14+
'status' => true,
15+
]);
16+
17+
$table->row([
18+
'id' => 2,
19+
'name' => 'Millie J.',
20+
'surname' => 'Koenig',
21+
'email' => '[email protected]',
22+
'status' => false,
23+
]);
24+
25+
$table->row([
26+
'id' => 3,
27+
'name' => 'Regina G.',
28+
'surname' => 'Hart',
29+
'email' => '[email protected]',
30+
'status' => true,
31+
]);
32+
33+
echo $table;

Examples/styled.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!usr/bin/php
2+
<?php
3+
declare(strict_types=1);
4+
require_once __DIR__ . '/../vendor/autoload.php';
5+
use InitPHP\CLITable\Table;
6+
7+
$table = new Table();
8+
$table->setBorderStyle(Table::COLOR_BLUE);
9+
$table->setCellStyle(Table::COLOR_GREEN);
10+
$table->setHeaderStyle(Table::COLOR_RED, Table::BOLD);
11+
12+
$table->setColumnCellStyle('id', Table::ITALIC, Table::COLOR_LIGHT_YELLOW);
13+
$table->setColumnCellStyle('email', Table::BOLD, Table::ITALIC);
14+
15+
$table->row([
16+
'id' => 1,
17+
'name' => 'Matthew S.',
18+
'surname' => 'Kramer',
19+
'email' => '[email protected]',
20+
'status' => true,
21+
]);
22+
23+
$table->row([
24+
'id' => 2,
25+
'name' => 'Millie J.',
26+
'surname' => 'Koenig',
27+
'email' => '[email protected]',
28+
'status' => false,
29+
]);
30+
31+
$table->row([
32+
'id' => 3,
33+
'name' => 'Regina G.',
34+
'surname' => 'Hart',
35+
'email' => '[email protected]',
36+
'status' => true,
37+
]);
38+
39+
echo $table;

README.md

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,109 @@
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+
'email' => '[email protected]',
29+
'status' => true,
30+
]);
31+
32+
$table->row([
33+
'id' => 2,
34+
'name' => 'Millie J.',
35+
'surname' => 'Koenig',
36+
'email' => '[email protected]',
37+
'status' => false,
38+
]);
39+
40+
$table->row([
41+
'id' => 3,
42+
'name' => 'Regina G.',
43+
'surname' => 'Hart',
44+
'email' => '[email protected]',
45+
'status' => true,
46+
]);
47+
48+
echo $table;
49+
```
50+
51+
Output :
52+
53+
![basic-cli-table](https://user-images.githubusercontent.com/104234499/186993361-3917979a-0a40-4e7b-84e8-4dd5f51c1bd1.jpg)
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+
'email' => '[email protected]',
76+
'status' => true,
77+
]);
78+
79+
$table->row([
80+
'id' => 2,
81+
'name' => 'Millie J.',
82+
'surname' => 'Koenig',
83+
'email' => '[email protected]',
84+
'status' => false,
85+
]);
86+
87+
$table->row([
88+
'id' => 3,
89+
'name' => 'Regina G.',
90+
'surname' => 'Hart',
91+
'email' => '[email protected]',
92+
'status' => true,
93+
]);
94+
95+
echo $table;
96+
```
97+
98+
Output :
99+
100+
![styled-cli-table](https://user-images.githubusercontent.com/104234499/186993365-82c0e55d-d572-45d2-a89a-5cf60c5c9fbe.jpg)
101+
102+
103+
## Credits
104+
105+
- [Muhammet ŞAFAK](https://github.com/muhammetsafak) <<[email protected]>>
106+
107+
## License
108+
109+
Copyright &copy; 2022 [MIT License](./LICENSE)

composer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "initphp/cli-table",
3+
"description": "PHP CLI Table Generator",
4+
"type": "library",
5+
"license": "MIT",
6+
"autoload": {
7+
"psr-4": {
8+
"InitPHP\\CLITable\\": "src/"
9+
}
10+
},
11+
"authors": [
12+
{
13+
"name": "Muhammet ŞAFAK",
14+
"email": "[email protected]",
15+
"role": "Developer",
16+
"homepage": "https://www.muhammetsafak.com.tr"
17+
}
18+
],
19+
"minimum-stability": "stable",
20+
"require": {
21+
"php": ">=7.2"
22+
}
23+
}

0 commit comments

Comments
 (0)