Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammetsafak committed Aug 26, 2022
1 parent 8b3eaec commit ef577a4
Show file tree
Hide file tree
Showing 7 changed files with 493 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Examples/ export-ignore
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.idea/
/.vscode/
/.vs/
/vendor/
/composer.lock
33 changes: 33 additions & 0 deletions Examples/basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!usr/bin/php
<?php
declare(strict_types=1);
require_once __DIR__ . '/../vendor/autoload.php';
use InitPHP\CLITable\Table;

$table = new Table();

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

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

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

echo $table;
39 changes: 39 additions & 0 deletions Examples/styled.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!usr/bin/php
<?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' => '[email protected]',
'status' => true,
]);

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

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

echo $table;
111 changes: 109 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,109 @@
# CLITable
PHP CLI Table
# 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
<?php
require_once __DIR__ . "/vendor/autoload.php";
use \InitPHP\CLITable\Table;

$table = new Table();

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

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

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

echo $table;
```

Output :

![basic-cli-table](https://user-images.githubusercontent.com/104234499/186993361-3917979a-0a40-4e7b-84e8-4dd5f51c1bd1.jpg)

### Styled

```php
<?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' => '[email protected]',
'status' => true,
]);

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

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

echo $table;
```

Output :

![styled-cli-table](https://user-images.githubusercontent.com/104234499/186993365-82c0e55d-d572-45d2-a89a-5cf60c5c9fbe.jpg)


## Credits

- [Muhammet ŞAFAK](https://github.com/muhammetsafak) <<[email protected]>>

## License

Copyright &copy; 2022 [MIT License](./LICENSE)
23 changes: 23 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "initphp/cli-table",
"description": "PHP CLI Table Generator",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"InitPHP\\CLITable\\": "src/"
}
},
"authors": [
{
"name": "Muhammet ŞAFAK",
"email": "[email protected]",
"role": "Developer",
"homepage": "https://www.muhammetsafak.com.tr"
}
],
"minimum-stability": "stable",
"require": {
"php": ">=7.2"
}
}
Loading

0 comments on commit ef577a4

Please sign in to comment.