simoneast/simple-ansi-colors
最新稳定版本:1.0.1
Composer 安装命令:
composer require simoneast/simple-ansi-colors
包简介
Simple PHP class for converting basic HTML-like color tags into ANSI escape codes for use in console apps and scripts. Auto-detection for Windows/Ansicon users included.
README 文档
README
Simple PHP class for converting basic HTML-like color tags into ANSI escape codes for use in console apps and scripts.
Can be disabled through a single variable so that no colors are output (such as if the output needs to be piped to another app or script).
Auto-detection for Windows/ANSICON users included. Colors are disabled by default on Windows unless ANSICON is detected.
Version 1.0.1
MIT Licence
Requires PHP 5.3 or above.
How to use
- Include the class in your script:
require('simple-ansi-colors.php'); - Output some text:
echo Ansi::tagsToColors('<green>Hello <yellow>World!');
Note that unlike HTML, there are no closing tags. Simply use <reset> to return the color to the default. For example...
<green>This text will be green. <reset>This text will return to the default color.
Supported tags
<black>
<red>
<green>
<yellow>
<blue>
<magenta>
<cyan>
<white>
<gray>
<darkRed>
<darkGreen>
<darkYellow>
<darkBlue>
<darkMagenta>
<darkCyan>
<darkWhite>
<darkGray>
<bgBlack>
<bgRed>
<bgGreen>
<bgYellow>
<bgBlue>
<bgMagenta>
<bgCyan>
<bgWhite>
<bold>
<italics>
<reset>
Run php demo.php to view a sample of all the options available. In consoles with ANSI color support, you'll see the following...
In the Windows command prompt (without ANSICON), color tags will simply be stripped out.
Windows users can download ANSICON and install it by running ansicon -i from a command prompt or "Run" window. This will allow them to view colors.
统计信息
- 总下载量: 40.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 1
- 依赖项目数: 9
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-05-26