Example #1
0
 * Output text to the console
 */
//Clear the screen before starting
\PHPCli\Cli::clear_screen();
\PHPCli\Cli::heading("Text Output");
\PHPCli\Cli::write("This is a plain string");
\PHPCli\Cli::write("This is a string with a Red text colour", \PHPCli\Color::$red);
\PHPCli\Cli::write("This is a string with a White text and Red Background", \PHPCli\Color::$white, \PHPCli\BackgroundColor::$red);
\PHPCli\Cli::write("Left Align", null, null, \PHPCli\Cli::$left);
\PHPCli\Cli::write("Center Align", null, null, \PHPCli\Cli::$center);
\PHPCli\Cli::write("Right Align", null, null, \PHPCli\Cli::$right);
$color = (include 'color.php');
$background_color = (include 'background_color.php');
foreach ($color as $text) {
    foreach ($background_color as $background) {
        \PHPCli\Cli::out(\PHPCli\Cli::color(" Text ", $text, $background));
    }
    \PHPCli\Cli::new_line();
}
\PHPCli\Cli::new_line(2);
\PHPCli\Cli::heading("Text Error Output");
\PHPCli\Cli::error("Failure: This is a plain error message");
\PHPCli\Cli::error("Failure: This is a error message with a yellow foreground colour", \PHPCli\Color::$yellow);
\PHPCli\Cli::error("Failure: This is a string with a white foreground and Red Background", \PHPCli\Color::$white, \PHPCli\BackgroundColor::$red);
\PHPCli\Cli::new_line(2);
\PHPCli\Cli::heading("Prompt for input");
//Prompt for input
$colour = \PHPCli\Cli::prompt("What is your favorite colour?");
\PHPCli\Cli::write("I also like " . $colour);
// Takes any input, but offers default
$colour = \PHPCli\Cli::prompt('What is your favorite color?', 'white');