1. Go to this page and download the library: Download testomat/terminal-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/ */
testomat / terminal-colour example snippets
declare(strict_types=1);
use Testomat\TerminalColour\Formatter;
$formatter = new Formatter();
// green text
$formatter->format('<info>foo</info>');
// yellow text
$formatter->format('<comment>foo</comment>');
// black text on a cyan background
$formatter->format('<question>foo</question>');
// white text on a red background
$formatter->format('<error>foo</error>');
declare(strict_types=1);
use Testomat\TerminalColour\Formatter;
use Testomat\TerminalColour\Style;
$style = new Style('red', 'yellow', ['bold', 'blink']);
$formatter = new Formatter(false, ['fire' => $style]);
$formatter->format('<fire>foo</fire>');
declare(strict_types=1);
use Testomat\TerminalColour\Formatter;
use Testomat\TerminalColour\StyleCode;
$style256 = new StyleCode(34); // will be transformed to '38;5;34' blue
$trueStyle = new StyleCode("38;2;1;1;1"); // same goes for 1;1;1 as value; will be transformed to '38;2;1;1;1'
$formatter = new Formatter(false, ['color256Blue' => $style256, 'trueColor' => $trueStyle]);
$formatter->format('<color256Blue>foo</color256Blue>');
// green text
$formatter->format('<fg=green>foo</>');
// black text on a cyan background
$formatter->format('<fg=black;bg=cyan>foo</>');
// bold text on a yellow background
$formatter->format('<bg=yellow;options=bold>foo</>');
// bold text with underscore
$formatter->format('<options=bold,underscore>foo</>');
declare(strict_types=1);
use Testomat\TerminalColour\Util;
echo Util::getNumberOfColumns(); // returns the number of the columns
echo Util::getSupportedColor(); // returns the supported color as int
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.