daijulong/console
Composer 安装命令:
composer require daijulong/console
包简介
A simple, lightweight console for php
README 文档
README
A simple, lightweight console for php
Require
- php: >= 5.4
Install
Via Composer
$ composer require daijulong/console
composer.json
"daijulong/console": "^1.1"
Usage
Output
Create a console instance
$console = \Daijulong\Console\Console::instance();
Print a message at the console
$console->text('I am a message!');
Print a message with a foreground color and a background color
$console->text('I am a message with red foreground color and yellow background color.', 'red', 'yellow');
You can get all supported colors from
Daijulong\Console\Color\Foreground::classandDaijulong\Console\Color\Background::class.
Print a message in a shortcut
$console->success('I am a success message.');
This will print a line of green text. Other similar methods are
error,warning,alertand more.
Input
Ask a question and get the answer
$name = $console->ask('Who are you?');
You can use second parameter as the default value. If there are third parameter equal to
true, the answer can not be empty, even if the default value is set.
Often, you just need to answer yes or no.
$bool = $console->yesOrNo('Are you going to give me your money?');
The console will be kept asking until you answer yes or no. Similarly, if any, the second parameter is the default value.
Other
Coloring string
$console->colored('I am a message with red foreground color and yellow background color.', 'red', 'yellow');
Similar to
text, it does not output directly, which is very useful in displaying a variety of styles in a piece of content.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 60
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-31