Is there a way to remove some commands from the php artisan list
?
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.
This php artisan clear-compiled command removes all the files from cache folder. To enable maintenance mode, we need to execute the down Artisan command: php artisan down Put the application into maintenance mode. To disable maintenance mode, we need to execute the up Artisan command: php artisan up Bring the application out of maintenance mode.
As updated by Bogdan, there is no good way to remove command from artisan list. One option available is to override the existing command with new command with same $signature. Show activity on this post.
Artisan is the console command line interface included with Laravel Framework. Artisan provides a number of helpful commands that can assist you while you build your Laravel application. How to use commands? To view list of available Artisan commands by following command.
To enable maintenance mode, we need to execute the down Artisan command: php artisan down Put the application into maintenance mode. To disable maintenance mode, we need to execute the up Artisan command: php artisan up Bring the application out of maintenance mode.
Just override the ArtisanServiceProvider for example:
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',
];
}
You see above i'm overriding the $devCommands for the full list
look inside Illuminate\Foundation\Providers\ArtisanServiceProvider
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
There's no good way to do that. Most of the core artisan commands list is stored in the Illuminate\Foundation\Providers\ArtisanServiceProvider
class within the $commands
property. Some are registered directly from their respective service providers, like the Queue ones in Illuminate\Queue\QueueServiceProvider
. So in theory you could comment them out there, but you should't be making any changes in the vendor
directory in the first place, because they can be undone on any update.
If you find yourself having to check the command list too often, you would be better off taking a little time to commit to memory at least the commands you use on a regular basis, because it would make your workflow far more efficient.
If by any chance you're using zsh with Oh My Zsh, then you could use the included laravel5
plugin which offers autocomplete in your terminal, for all registered Laravel commands. Just write php artisan
and press TAB for an autocomplete list of the commands, no scrolling required :).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With