阅读(4990) (8)

Laravel 8 编写输出

2021-06-30 15:43:35 更新

要发送输出到控制台,请使用 lineinfocommentquestionerror 方法。每一个方法都使用适当的 ANSI 颜色以表明其目的。例如,让我们为用户显示一些普通信息。通常情况下,info 方法将会在控制台中显示绿色文本:

/**
 * 执行控制台命令
 *
 * @return mixed
 */
public function handle()
{
    $this->info('Display this on the screen');
}

您可以使用 error 方法来显示错误信息。错误信息通常以红色文本显示:

$this->error('Something went wrong!');

如果您想要显示没有着色的输出,请使用 line 方法:

$this->line('Display this on the screen');