0

Why php artisan run all commands in the folder Commands when I create a model for example ? Did I made something wrong ?

ManojKiran A
  • 5,896
  • 4
  • 30
  • 43
Eloise85
  • 648
  • 1
  • 6
  • 26

2 Answers2

3

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.

ManojKiran A
  • 5,896
  • 4
  • 30
  • 43
-4

Artisan is the command line interface included with Laravel. Artisan exists at the root of your application as the artisan script and provides a number of helpful commands that can assist you while you build your application.

See more at : https://laravel.com/docs/8.x/artisan