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()来检索输出对象.

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

然后,您可以将该级别与OutputInterface内定义的常量进行比较.例如:

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

Laravel相关问答推荐

try 编写一个函数,如果产品存在,则无法删除特定类别

使用 Laravel 10 在 Blade 中添加成功消息

如何使用PHP版本8.2.6安装beyondcode/laravel-websockets软件包?

Dompdf 古吉拉特语和印地语文本未正确显示

Laravel:在行的子集上同步多对多

在 Laravel 中清除 Routes&config:cache 后未定义的常量

如何为 CMP 横幅安装谷歌同意脚本?

向 Laravel 模型查询添加计算字段

在 VSCode 上调试 Laravel 应用程序

在 laravel 查询构建器中使用多个 where 子句

静态密码在默认的 Laravel 用户工厂中是如何工作的?

Laravel 4:读取由 javascript 设置的 cookie

不支持驱动Driver[] - Laravel 5.3

在 Laravel Eloquent 中,limit 与 take 有什么区别?

Laravel - 自定义时间戳列名称

命令未定义异常

Laravel 错误声明 App\Exceptions\Handler::report(Throwable $exception)

如何在 Laravel Mix 中将公共路径更改为包含下划线的内容?

Laravel s3 多桶

Laravel 部署……有标准的方式吗?