Reputation: 949
I am working on a CLI application based on Laravel 5.4.
I have created my custom commands and they are working as expected.
The issue, I am facing is, whenever I run php artisan list
, it shows all commands - my custom commands and default artisan commands.
I need to show only my custom commands in packaged app.
Is there any way to solve this?
I have already checked https://laracasts.com/discuss/channels/general-discussion/remove-default-commands-from-artisan and solution given there is not working for Laravel 5.4.
I have checked Remove command from php artisan list but it asks for specific commands. I want to remove all built-in commands from php artisan list
.
Update
I have found a dirty way:
If I comment out line #58 from framework/src/Illuminate/Console/Application.php
$this->bootstrap();
i.e. https://github.com/laravel/framework/blob/5.4/src/Illuminate/Console/Application.php#L58 output is as expected.
Now I am looking for a way to stop/control bootstrap()
function/process.
Upvotes: 2
Views: 2698
Reputation: 906
If you want to hide the default commands you can override them by creating a command with the same signature then add.
protected $hidden = true;
To the class.
Upvotes: 0
Reputation: 8288
To hide a command from php artisan list
-this will only hide the command and won't disable it-
before going into how to hide it, let's take a look at the property $hidden
inside the the Illuminate\Console\Command
object , by default it's a false , when you set it to true , you will get all of your artisan list hidden.
and to hide a specific command , you will need to set this property to hidden inside each class you want to hide it's command ,
for example , when you hit php artisan list
will prompt a list as follows :
.....
cache
cache:clear Flush the application cache
cache:forget Remove an item from the cache
cache:table Create a migration for the cache database table
.....
this means that , the object which is responsible about clearing the cache
is located into Illuminate\Cache\Console
.
now to hide the cache:clear command , inside Illuminate\Cache\Console you will get ClearCommand.php
object .
update it and set the property $hidden
to true , as follows :
protected $hidden = true;
Upvotes: 3