antibiotics11 / ansi-styler
将 ANSI 颜色和文本样式应用到控制台输出的实用工具。
v1.0
2024-04-15 07:45 UTC
README
一个用于将 ANSI 颜色和文本样式应用到控制台输出的 PHP 实用工具。
use antibiotics11\AnsiStyler\{AnsiColorCode, AnsiFormatter}; // create a new AnsiFormatter instance $styler = new AnsiFormatter(); // apply yellow background color, red foreground color and bold style $formattedText = $styler->withBackgroundColor(AnsiColorCode::BACKGROUND_YELLOW) ->withForegroundColor(AnsiColorCode::FOREGROUND_RED) ->withBold() ->format("Hello, World!"); printf("%s\r\n", $formattedText); // reinitialize the AnsiFormatter $styler->initialize();
要求
- PHP >= 8.1
安装
composer require antibiotics11/ansi-styler
