Why php artisan run all commands in the folder Commands when I create a model for example ? Did I made something wrong ?
Laravel will initialize
all the commands (User defined and Default commands) whenever you run any command in laravel application.
Which means don't perform any operation in __construct
method of the commands.
For Example:
If you are performing any Databse operation in __construct
method of custom command it will perform Databse operation no matter what command to ran.
So Move all the logics and operations to handle
method of command.
I have faced the same issue back in the day You can see the github issue to clarify.