irfantoor / console
0.6.2
2020-03-28 19:18 UTC
Requires
- php: >= 7.2
README
带有颜色的基本控制台。
使用方法
请查看示例文件夹中的不同示例。
<?php require dirname(__DIR__) . "/vendor/autoload.php"; use IrfanTOOR\Console; $c = new Console; # printing with style $c->write("Hello ", "green"); $c->writeln("World ", "red"); # when a string of texts is given, a banner is printed $c->writeln(['Its a banner'], ['bg_blue','white']); # reading from console $response = $c->read("Are you ok? [Y/N]", "info"); $c->write("you responded with: "); $c->writeln($response, ["info", "reverse"]);
样式
前景样式
- 无
- 加粗
- 深色
- 斜体
- 下划线
- 闪烁
- 反色
- 隐藏
- 默认
- 黑色
- 红色
- 绿色
- 黄色
- 蓝色
- 品红色
- 青色
- 浅灰色
- 深灰色
- 浅红色
- 浅绿色
- 浅黄色
- 浅蓝色
- 浅品红色
- 浅青色
- 白色
背景样式
- 默认背景
- 黑色背景
- 红色背景
- 绿色背景
- 黄色背景
- 蓝色背景
- 品红色背景
- 青色背景
- 浅灰色背景
- 深灰色背景
- 浅红色背景
- 浅绿色背景
- 浅黄色背景
- 浅蓝色背景
- 浅品红色背景
- 浅青色背景
- 白色背景
主题样式
- 信息
- 错误
- 警告
- 成功
- 注意
- 脚注
- 网址
注意:所有主题样式都可以在创建控制台时提供定义进行修改,或者使用 setTheme 函数。
<?php $c = new IrfanTOOR\Console([ 'info' => ['bg_black', 'yellow'], 'url' => ['red', 'underline'], ]); # Theme $c->writeln("Modified theme >> info", "info"); $c->writeln("https://github.com/irfantoor/console", "url"); $c->setTheme([ 'url' => ['red', 'bg_yellow', 'underline'] ]); $c->writeln("https://github.com/irfantoor/console", "url");