Search code examples
phplaravellaravel-5laravel-artisanartisan-migrate

Extend Laravel's Default Commands or Block them on production?


There are a few Artisan commands that I do not want to be run on production. For example, I would like to block the use of php artisan migrate:reset on production.

I would like to completely block this command OR Update the template artisan uses when running php artisan make:migration. The reason for updating the template is so I can make the template extend a different Class instead of the Migration class. In this new class I can inject my custom protection logic. I just don't want other developers using the artisan command and extending the wrong class.


Solution

  • Well,

    1. Laravel will always ask for confirmation when you run migration commands in production, for safety purposes.

    2. Other developers shouldn't have access to your production. Normally, almost none of the developers have access to production. And even if they did, why would they run migration commands there?

    If you are still sure you want to do this, you could just add a very simple condition (if app()->environment('production')) when you load the command in the bootstrap process or inside the command class itself.