Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

JBlond/php-cli

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-cli

composer require jblond/php-cli

php command line / cli scripting classes

Example

<?php
use jblond\cli\Cli;
use jblond\cli\CliColors;

$cli = new Cli();
$colors = new CliColors();

$string = $colors->getColoredString('This is a test','red','black');
$cli->output($string); // normal 
$cli->error($string); // error 

// This input requires Hello or world as input
$cli->input('Hello world: ',array('Hello','world'));

// This input requires only test

$cli->input('Test2: ', 'test');


// This input requires any input

$cli->input('Free input: ', '');

// Question with default N 
$answer = $cli->input('Do this? y/N', array('y','n','Y','N'), 'N');
echo $answer;

Inspired by the php.net docs http://php.net/manual/en/features.commandline.io-streams.php

and a modified version of http://www.if-not-true-then-false.com/2010/php-class-for-coloring-php-command-line-cli-scripts-output-php-output-colorizing-using-bash-shell-colors/

About

php command line / cli scritping and coloring classes

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.