The Importance of Stopping Destructive Commands

Matt Yeend avatar
, , , , ,

One of the main differences between a local environment and a production one, is the ability to run the majority, if not all, of the Artisan commands via the terminal. However, you might not want to allow this to happen in a production environment.

One of the easiest ways to stop this would be to update your AppServiceProvider file within your Laravel project, and to create an array of different commands such as 'migrate:fresh', 'migrate:reset', and 'db:wipe' which would drop all tables, roll back all migrations, and drops all databases respectfully.

As long as you loop through the array and declare the Illuminate\Support\Facades\Artisan facade at the top to use the Artisan::command in order to use a $this->error to stop the commands from running.