PHP Simple Console
composer require vaneves/console
require_once('../vendor/autoload.php');
use Vaneves\Console\Console;
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:
===================================
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!
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:
74/150 [βββββββββββββββββββββββββ] 49%
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:
+---------------+------------------+----------------+
| name | domain | profession |
+---------------+------------------+----------------+
| Van Neves | vaneves.com | PHP Developer |
| Luiz Carvalho | luizcarvalho.com | Ruby Developer |
| Nyl Marcos | | PHP Developer |
+---------------+------------------+----------------+
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:
Apples.........$0.99
Bananas........$0.39
Clementines....$3.99
Lemons.........$0.69
Strawberriess..$1.99