We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track

use Illuminate\Console\Command; > use Illuminate\Console\Prohibitable; > > class SomeDestructiveCommand extends Command > { > use Prohibitable; > } > > // SomeDestructiveCommand::prohibit($this->app->isProduction()); > ``` > > The Laravel framework includes some database commands that include the `Prohibitable` trait, such as `db:wipe`, > `migrate:fresh`, `migrate:refresh`, and `migrate:reset`: > > ```php public function boot(): void > { > FreshCommand::prohibit(); > RefreshCommand::prohibit(); > ResetCommand::prohibit(); > WipeCommand::prohibit(); > } > ``` > > Using the `DB` Facade, you can prohibit destructive database commands built into Laravel: > > ```php // Prohibits: db:wipe, migrate:fresh, migrate:refresh, and migrate:reset > DB::prohibitDestructiveCommands($this->app->isProduction()); > ``` > > The `prohibit()` method accepts a `Boolean` argument that defaults to `true`, and you can conditionally prevent commands > from running using whatever logic you need, so that you can still run them in development environments: > > ```php public function boot(): void > { > YourCommand::prohibit($this->app->isProduction()); > } > ```As of Laravel 11.9 you can now prevent commands like database migrations from accidentally running in production environments with a
Prohibitable
trait:
continue reading on laravel-news.com
⚠️ This post links to an external website. ⚠️
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.