https://github.com/vaneves/console
💻 PHP Simple Console
https://github.com/vaneves/console
cli console console-color php terminal
Last synced: about 1 month ago
JSON representation
💻 PHP Simple Console
- Host: GitHub
- URL: https://github.com/vaneves/console
- Owner: vaneves
- License: mit
- Created: 2022-03-20T22:52:21.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-25T00:44:17.000Z (about 4 years ago)
- Last Synced: 2025-08-17T14:41:28.690Z (10 months ago)
- Topics: cli, console, console-color, php, terminal
- Language: PHP
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Console
PHP Simple Console
## Install
```bash
composer require vaneves/console
```
## Basic Usage
```php
require_once('../vendor/autoload.php');
use Vaneves\Console\Console;
```
### Console
```php
use Vaneves\Console\Console;
$console = new Console();
$console->title('A highlighted title for the section');
$console->line('A regular line.');
$console->success('Operation executed successfully!');
$console->info('This is just highlighted information.');
$console->warning('This requires your attention!');
$console->error('Oops! Error during execution!');
$console->comment('Just a comment.');
$console->comment('Just a comment without slash.', false);
$console->successWithIcon('Operation executed successfully!');
$console->infoWithIcon('This is just highlighted information.');
$console->warningWithIcon('This requires your attention!');
$console->errorWithIcon('Oops! Error during execution!');
$console->successWithIcon('Operation executed successfully!', '❤');
$console->infoWithIcon('This is just highlighted information.', '➥');
$console->warningWithIcon('This requires your attention!', '➤');
$console->errorWithIcon('Oops! Error during execution!', '✖');
```
Output:
```bash
===================================
A highlighted title for the section
===================================
A regular line.
Operation executed successfully!
This is just highlighted information.
This requires your attention!
Oops! Error during execution!
// Just a comment.
Just a comment without slash.
✔ Operation executed successfully!
☛ This is just highlighted information.
⚠ This requires your attention!
✘ Oops! Error during execution!
❤ Operation executed successfully!
➥ This is just highlighted information.
➤ This requires your attention!
✖ Oops! Error during execution!
```
### Progress
```php
use Vaneves\Console\Progress;
$total = 150;
$progress = new Progress($total);
$progress->start();
for ($i = 1; $i <= $total; $i++) {
$progress->advance();
usleep(30000);
}
$progress->finish();
```
Output:
```bash
74/150 [▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░] 49%
```
### Table
```php
use Vaneves\Console\Table;
$data = [
[
'name' => 'Van Neves',
'domain' => 'vaneves.com',
'profession' => 'PHP Developer',
],
[
'name' => 'Luiz Carvalho',
'domain' => 'luizcarvalho.com',
'profession' => 'Ruby Developer',
],
[
'name' => 'Nyl Marcos',
'domain' => '',
'profession' => 'PHP Developer',
],
];
$table = new Table($data);
$table->show();
```
Output:
```bash
+---------------+------------------+----------------+
| name | domain | profession |
+---------------+------------------+----------------+
| Van Neves | vaneves.com | PHP Developer |
| Luiz Carvalho | luizcarvalho.com | Ruby Developer |
| Nyl Marcos | | PHP Developer |
+---------------+------------------+----------------+
```
### Padding
```php
use Vaneves\Console\Padding;
$padding = new Padding(20);
$padding->line('Apples', '$0.99');
$padding->line('Bananas', '$0.39');
$padding->line('Clementines', '$3.99');
$padding->line('Lemons', '$0.69');
$padding->line('Strawberriess', '$1.99');
```
Output:
```bash
Apples.........$0.99
Bananas........$0.39
Clementines....$3.99
Lemons.........$0.69
Strawberriess..$1.99
```