PHP Command line colored input
/**
* Prompt a colored message for user
*
* @param string $msg message string
* @param string $color RED | YELLOW | null (default color)
*/
function prompt($msg,$color = null){
$colors = [
'RED' => '\033]31m',
'YELLOW' => '\033]33m'
];
$promptMsg = $msg . '\n';
if ($color != null){
$promptMsg = $colors[$color] . $promptMsg;
}
echo $promptMsg;
}
/**
* Prompt a colored message for user, which will wait and return user input
*
* @param string $msg message string
* @param string $color RED | YELLOW | null (default color)
*/
function question($msg,$color){
prompt($msg,$color);
return fgets(STDIN);
}
// add your extra color here!
http://blog.lenss.nl/2012/05/adding-colors-to-php-cli-script-output/