【问题标题】:How to list my custom commands only (Laravel)?如何仅列出我的自定义命令(Laravel)?
【发布时间】:2021-12-29 06:15:59
【问题描述】:

Laravel 有 php artisan list 命令。它显示所有可用的命令。 我在app/Console/Commands 文件夹中创建了一堆自定义命令。我在所有命令的列表中看到它们。但是有没有办法只在该列表中显示我的命令?要从该列表中隐藏 Laravel 内置命令?

【问题讨论】:

  • 假设我创建了命令php artisan ip:add。然后是另外 10 个命令。如何列出它们?如何只列出我的命令?
  • 最好将自定义命令放在自定义命名空间下。因此,出于上述确切原因,您应该使用petr:ip:add 而不是ip:add 。

标签: php laravel laravel-artisan


【解决方案1】:

如果你输入

php artisan list -help

会输出

 The list command lists all commands:
  
    artisan list
  
  You can also display the commands for a specific namespace:
  
    artisan list test

所以如果你的命令放在你自己的命名空间下,例如。 petr你可以跑了

php artisan list petr

只查看该命名空间下的命令。

【讨论】:

  • 是的,我知道命名空间。但是我们有多个命名空间。
  • php artisan list one-namespace && php artisan list two-namespaces 或 php artisan list | grep <your-grep-here>
猜你喜欢
  • 2015-04-06
  • 2019-09-19
  • 2011-04-17
  • 1970-01-01
  • 2020-09-20
  • 2021-08-11
  • 2016-05-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多