alecrabbit/php-console-colour

帮助进行彩色控制台输出。


README

PHP Version Build Status Scrutinizer Code Quality Code Coverage Total Downloads

Latest Stable Version Latest Version Latest Unstable Version

License

安装

composer require alecrabbit/php-console-colour

Themes::class

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

基本上这个类的方法只是将对应的转义序列应用到 $text

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

注意:并非所有方法都能列出。

/**
 * @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)
 */

注意:将添加新方法。欢迎提交拉取请求。

定义自己的主题

ConsoleColor::class

// TODO

XTerm 256 颜色表

example

示例

example

example

注意:实际颜色取决于您的终端颜色方案

链接