PHP code example of pointybeard / helpers-cli-colour
1. Go to this page and download the library: Download pointybeard/helpers-cli-colour library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pointybeard / helpers-cli-colour example snippets
ointybeard\Helpers\Cli\Colour;
// Access colour constants
$foreground = Colour\Colour::FG_RED;
$background = Colour\Colour::BG_LIGHT_YELLOW;
try{
// Add colour to a string
print Colour\Colour::colourise(
"This is my colouful string!!",
$foreground,
$background
);
print PHP_EOL;
// Throws a InvalidColourException exception if the colour is invalid
Colour\Colour::colourise(
"Some string",
"banana",
$background
);
} catch (Colour\Exceptions\InvalidColourException $ex) {
print "ERROR: " . $ex->getMessage() . PHP_EOL;
}