1. Go to this page and download the library: Download bebat/console-color 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/ */
bebat / console-color example snippets
use BeBat\ConsoleColor\Style;
$style = new Style();
echo $style->apply('This text is green', Style\Color::Green) . PHP_EOL;
use BeBat\ConsoleColor\Style;
$handle = fopen($something, 'w');
$style = new Style($handle);
fwrite($handle, $style->apply(
'If $something points to a console this text will have a cyan background. ' .
'Otherwise it will just be plain.',
Style\BackgroundColor::Cyan,
));
use BeBat\ConsoleColor\Style;
$handle = fopen($something, 'w');
$style = new Style($handle);
$style->force();
fwrite($handle, $style->apply(
'This text will always have styling applied to it.', Style\Text::Bold,
));
use BeBat\ConsoleColor\Style;
$style = new Style();
echo $style->apply(
'This text is white on red',
new Style\Composite(Style\Color::BrightWhite, Style\BackgroundColor::Red),
) . PHP_EOL;
use BeBat\ConsoleColor\Style;
$style = new Style();
echo $style->apply(
'This text has a typo',
new Style\Composite(Style\Underline::Wavy, Style\ColorRGB::underline(255, 0, 0)),
) . PHP_EOL;
use BeBat\ConsoleColor\Style;
$style = new Style();
echo $style->apply(
"Please don't do this\n",
new Style\Composite(
Style\Text::Bold,
Style\Text::Italic,
Style\Text::Blink,
Style\Color256::background(34),
Style\Color256::foreground(227),
),
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.