alecrabbit/php-console-colour

Helps to do colored console output.

0.5.5 2019-08-15 14:50 UTC

README

PHP Version Build Status Scrutinizer Code Quality Code Coverage Total Downloads

Latest Stable Version Latest Version Latest Unstable Version

License

inspired by JakubOnderka/PHP-Console-Color

Installation

composer require alecrabbit/php-console-colour

Themes::class

Usage
$themes = new Themes();
echo $themes->red('This text is red.') . PHP_EOL;
echo $themes->underlinedBold('This text is underlined and bold.') . PHP_EOL;

Basically methods of this class just applying corresponding escape sequences to $text

// "\033[2;3mThis text is dark and italic.\033[0m"
$colorized = $themes->darkItalic('This text is dark and italic.')
Methods

Note: not all methods could be listed.

/**
 * @method comment(string $text)
 * @method error(string $text)
 * @method info(string $text)
 *
 * @method yellow(string $text)
 * @method red(string $text)
 * @method green(string $text)
 * @method cyan(string $text)
 * @method magenta(string $text)
 *
 * @method italic(string $text)
 * @method bold(string $text)
 * @method dark(string $text)
 * @method darkItalic(string $text)
 * @method white(string $text)
 * @method whiteBold(string $text)
 * @method underlined(string $text)
 * @method underlinedBold(string $text)
 * @method underlinedItalic(string $text)
 */

Note: new methods will be added. Pull requests are welcomed.

Define your own themes

ConsoleColor::class

// TODO

Examples

example

example

Note: actual colors depend on your terminal color scheme

Links