1. Go to this page and download the library: Download weew/console-formatter 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/ */
weew / console-formatter example snippets
$formatter = new ConsoleFormatter();
$style = (new ConsoleStyle('alert'))
->setColor(ConsoleColor::WHITE)
->setBackground(ConsoleBackground::RED)
->setFormat([ConsoleFormat::BOLD, ConsoleFormat::UNDERLINE]);
$formatter->addStyle($style);
// or
$formatter->style('alert')
->setColor(ConsoleColor::WHITE)
->setBackground(ConsoleBackground::RED)
->setFormat([ConsoleFormat::BOLD, ConsoleFormat::UNDERLINE]);
// or
$formatter->style('alert')
->parseStyle('clr=white bg=red fmt=bold,underline');
echo $formatter->format('<alert>text</alert>');
echo $formatter->format('<style clr=red bg=white>red text on white background</style>');
$formatter->format('<alert clr=yellow>alert style with yellow text</alert>');