Remove command from php artisan list

Is there a way to remove some commands from php artisan list ?

I find it to be too long and often I have to scroll or do grepping. For example, some project that I do not use in the queue, and hiding the queue commands will be useful.

+6
source share
5 answers

Alight. I finally got a good solution. Create your own bash alias with grep.

Add this to my ~ / .bashrc

My whole team starts with mycompany: team

Use any combination of 3 letters. can for me because this is the first 3rd letter of my company name.

 alias can='php artisan | grep mycompany' 
-1
source

Just override ArtisanServiceProvider, for example:

create a new provider will be called ProductionArtisanServiceProvider

 php artisan make:provider ProductionArtisanServiceProvider 

Open a 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', ]; } 

You see above, I override $ devCommands for a complete list

take a look inside Illuminate \ Foundation \ Providers \ ArtisanServiceProvider

Finally, you have the AppServiceProvider in the register function, add a new provider and make sure that it is loaded only in the production environment

  if ($this->app->environment() == 'production') { $this->app->register(\App\Providers\ProductionArtisanServiceProvider::class); } 

Now all unnecessary commands are gone

+5
source

There is no good way to do this. Most of the main wizard command commands are stored in the Illuminate\Foundation\Providers\ArtisanServiceProvider in the $commands property. Some are registered directly with their respective service providers, such as Queue in Illuminate\Queue\QueueServiceProvider . Therefore, theoretically, you can comment on them there, but you should not make changes to the vendor directory in the first place, because they can be undone during any update.

If you have to check the list of commands too often, you would be better off spending some time fixing the memory, at least on the commands that you use on a regular basis, because it will make your workflow far .


If you accidentally use zsh with Oh My Zsh , you can use the included laravel5 plugin, which offers autocomplete in your terminal for all registered Laravel commands. Just write php artisan and press TAB for a list of autocomplete commands, without scrolling :).

+3
source

As updated by Bogdan, there is no good way to remove a team from the list of masters. One option is to override the existing command with a new command with the same $signature.

0
source

If all the commands that interest you begin with the same prefix, for example prefix: you can list them using the artisan list prefix .

0
source

Source: https://habr.com/ru/post/988617/


All Articles