output instance
输出实例
输出对象是
Inhere\Console\IO\Output的实例
基本输出:
public function write(mixed $messages = '', bool $nl = true, bool $quit = false, array $options = [])
-
$messagesmixed 要输出的消息。可以是字符串或数组。 -
$nlbool 输出后是否换行。 默认true -
$quitbool|int 输出后是否退出脚本。默认false, 其它值都会转换为int作为退出码(true会转换为 0)。 -
$optionsarray 选项信息
$output->write('hello'); $output->write(['hello', 'world']);
带颜色风格的输出
$output 的 write() 方法支持带颜色风格的输出(当然得终端支持才行)
$output->write('hello <info>world<info>');
已经内置了常用的风格:

来自于类 Inhere\Console\Util\Show。
output 实例拥有
Inhere\Console\Util\Show的所有格式化输出方法。不过都是通过对象式访问的。
单独使用颜色风格
$style = Inhere\Console\Component\Style\Style::create(); echo $style->render('no color <info>color text</info>'); // 直接使用内置的风格 echo $style->info('message'); echo $style->error('message');