CrookClaw's avatar

Remove default commands from Artisan

Hi Guys,

I want to create a set of CLi commands for development puposes. I would like to remove the default commands from Artisan so only my custom commands are left. Does anyone know how I can accomplish this?

Thanks in advance!

0 likes
4 replies
mstnorris's avatar

Why would you want to do that? I don't think you can as I'm sure they are outside of the project scope. It looks like they are in the illuminate/foundation namespace, so whenever you update Laravel, any changes you make will be overwritten.

I'm not sure exactly where they are, but you can always check the API.

MaxMatteo's avatar

for anyone interested:

add to your Console Kernel Class

protected $includeDefaultCommands = false; 
1 like
rahul286's avatar
protected $includeDefaultCommands = false; 

Above workaround is not working on Laravel 5.4

Seems it's removed around 5.1. or 5.1.

Is there any alternative added?

ChristiaanL's avatar

In Laravel 5.4, the default artisan commands are registered in Illuminate\Foundation\Providers\ArtisanServiceProvider which, in turn, is registered by Illuminate\Foundation\Providers\ConsoleSupportServiceProvider.

See ArtisanServiceProvider See ConsoleSupportServiceProvider

If you extend the ArtisanServiceProvider and provide your own values for protected $commands = [];, then also extend ConsoleSupportServiceProvider to register your provider instead, you will be able to set default command.

1 like

Please or to participate in this conversation.