从php artisan列表中删除命令 [英] Remove commands from php artisan list
问题描述
是否可以从php artisan list
中删除某些命令?
Is there a way to remove some commands from the php artisan list
?
我发现它太长了,经常需要滚动或grepping.例如,某些我不使用队列的项目,隐藏队列命令将很有用.
I find that it is too long and often I have to scroll or do grepping. For example, some project I don't use queue and hiding the queue commands will be useful.
推荐答案
只需覆盖ArtisanServiceProvider,例如:
Just override the ArtisanServiceProvider for example:
创建一个新的提供程序将其命名为ProductionArtisanServiceProvider
create a new provider will name it ProductionArtisanServiceProvider
php artisan make:provider ProductionArtisanServiceProvider
打开新的提供程序并将其更改为以下内容
Open up the new provider and change it to the following
namespace App\Providers;
use Illuminate\Foundation\Providers\ArtisanServiceProvider as IlluminateProvider;
class ProductionArtisanServiceProvider extends IlluminateProvider
{
protected $devCommands = [
'AppName' => 'command.app.name',
];
}
您在上方看到我覆盖了$ devCommands 查看完整列表
You see above i'm overriding the $devCommands for the full list
在Illuminate \ Foundation \ Providers \ ArtisanServiceProvider内部查看
look inside Illuminate\Foundation\Providers\ArtisanServiceProvider
最后在您的AppServiceProvider中的register函数中添加新的提供程序,我们确保它仅在生产环境中加载
Finally in you AppServiceProvider in the register function add your new provider and we make sure it's only loaded in the production environment
if ($this->app->environment() == 'production') {
$this->app->register(\App\Providers\ProductionArtisanServiceProvider::class);
}
现在所有不必要的命令都消失了
Now all the unnecessary commands are gone
这篇关于从php artisan列表中删除命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!