czproject/phpcli

Helper class for PHP CLI apps.

v3.0.0-beta3 2018-06-08 14:51 UTC

README

Become a Patron! Buy me a coffee

Installation

Download a latest package or use Composer:

composer require czproject/phpcli

PhpCli requires PHP 5.3.0 or later, optionaly Readline extension.

Usage

use CzProject\PhpCli\ConsoleFactory;

require __DIR__ . '/vendor/autoload.php';

$console = ConsoleFactory::createConsole();

// output
$console->success('CzProject CLI Simple Console')
	->nl() // new line
	->warning('Hey!')
	->nl()
	->info('Fred!')
	->nl()
	->error('Fred is dead!')
	->nl()
	->muted('nooooooo...!', ' ', 'But, no problem!')
	->nl()
	->output('The end.')
	->nl();

// input
$username = $console->input('Enter your name:');

$console->info('Hello! ')
	->success($username)
	->warning(' [user]')
	->nl() // print new line
	->info('Bye!')
	->nl();

License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/