在Laravel工匠命令中使用详细 [英] Using verbose in Laravel artisan commands

查看:88
本文介绍了在Laravel工匠命令中使用详细的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以检测用户在创建自定义工匠命令时指定的详细级别?我在文档中什么都没有看到.

Is there a way to detect what verbosity level the user has specified when creating a custom artisan command? I don't see anything about it in the docs.

推荐答案

Symfony\Component\Console\Output\OutputInterface中有getVerbosity()函数,您可以使用$this->getOutput()检索输出对象.

There's the getVerbosity() function in Symfony\Component\Console\Output\OutputInterface and you can use $this->getOutput() to retrieve the output object.

$verbosityLevel = $this->getOutput()->getVerbosity();

然后您可以将级别与OutputInterface中定义的常数进行比较.例如:

You then can compare the level to the constants defined inside OutputInterface. For example:

if($verbosityLevel >= OutputInterface::VERBOSITY_VERBOSE){
    // show verbose messages
}

这篇关于在Laravel工匠命令中使用详细的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆