PHPackages                             mattyeend/prevent-destructive-commands - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. mattyeend/prevent-destructive-commands

ActiveLibrary[Database &amp; ORM](/categories/database)

mattyeend/prevent-destructive-commands
======================================

A Laravel package to stop destructive commands.

v1.1.11(1mo ago)21501MITPHPPHP &gt;=8.1

Since Jan 9Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/MatthewYeend/Prevent-Destructive-Commands)[ Packagist](https://packagist.org/packages/mattyeend/prevent-destructive-commands)[ Fund](https://www.buymeacoffee.com/mattyeend)[ GitHub Sponsors](https://github.com/MattYeend)[ RSS](/packages/mattyeend-prevent-destructive-commands/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (12)Used By (0)

Prevent Destructive Commands
============================

[](#prevent-destructive-commands)

Prevent Destructive Commands is a Laravel package that disables certain destructive Artisan commands in production environments to protect your database and application data.

---

Features
--------

[](#features)

This package disables the following commands when the application is in the production environment:

- `php artisan migrate:fresh` - Drops all tables and re-runs migrations.
- `php artisan migrate:reset` - Rolls back all migrations.
- `php artisan migrate:rollback` - Rolls back a batch of migrations.
- `php artisan db:wipe` - Drops all databases. In non-production environments, these commands will function as usual.

---

Installation
------------

[](#installation)

1. Install via Composer: `composer require MattYeend/prevent-destructive-commands`

---

Compatibility
-------------

[](#compatibility)

This package is compatible with Laravel 10, 11, and 12.

---

Registration
------------

[](#registration)

### Laravel 10, 11, and 12

[](#laravel--10-11-and-12)

For Laravel 10, 11, and 12, nothing needs to be done to register the package after install.

---

Usage
-----

[](#usage)

The package automatically disables destructive commands in the production environment. No additional setup is required.

---

### Running a Disabled Command in Production

[](#running-a-disabled-command-in-production)

If you attempt to run any of the disabled commands in a production environment, you’ll receive an error message like: `This 'migrate:fresh' command is disabled in this environment for safety.`In non-production environments (e.g., `local`, `staging`), the commands will execute normally.

---

### Environment Configuration

[](#environment-configuration)

Ensure your `.env` file correctly specifies the application environment: `APP_ENV=production`The package determines the current environment using Laravel’s `app()->environment()` method.

#### Testing

[](#testing)

You can simulate the package behavior by temporarily setting your application environment to `production`. To do this:

1. Edit `.env`

```
APP_ENV=production
```

2. Attempt to run a destructive command, e.g.:

```
php artisan migrate:fresh
```

3. You should see an error message similar to the following:

```
This 'migrate:fresh' command is disabled in this environment for safety.
```

##### Testing through package

[](#testing-through-package)

1. Install dependencies

```
composer install
```

2. Run the test

```
composer test
```

---

License
-------

[](#license)

This package is licensed under the MIT License.

---

Contributing
------------

[](#contributing)

Feel free to fork the repository and submit pull requests for improvements or new features!

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance98

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~44 days

Recently: every ~98 days

Total

11

Last Release

43d ago

PHP version history (2 changes)v1.1.1PHP ^7.4 || ^8.0

v1.1.6PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/280b020ca627b367261832c86f63f9f71076d720e1f8e6c4a7ae2c9c1a77f39e?d=identicon)[MattYeend](/maintainers/MattYeend)

---

Top Contributors

[![MattYeend](https://avatars.githubusercontent.com/u/23270321?v=4)](https://github.com/MattYeend "MattYeend (16 commits)")[![Rohaq](https://avatars.githubusercontent.com/u/246865?v=4)](https://github.com/Rohaq "Rohaq (1 commits)")

---

Tags

commandscomposercomposer-packagedatabasedesctructive-commandsdestructivelaravellaravel-10laravel-11laravel-12laravel-frameworklaravel-packagelaravel10laravel11laravel12packagephppreventprevent-destructiveprevent-destructive-commandslaravelpackagecommandspreventDestructivePrevent-Destructive-Commands

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mattyeend-prevent-destructive-commands/health.svg)

```
[![Health](https://phpackages.com/badges/mattyeend-prevent-destructive-commands/health.svg)](https://phpackages.com/packages/mattyeend-prevent-destructive-commands)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[belamov/postgres-range

Postgres range types support for laravel

38224.9k1](/packages/belamov-postgres-range)[awssat/laravel-sync-migration

Laravel tool helps to sync migrations without refreshing the database

10923.2k](/packages/awssat-laravel-sync-migration)[onramplab/laravel-custom-fields

An laravel package that enables custom field support for any Laravel models

103.9k](/packages/onramplab-laravel-custom-fields)[alexeykhr/laravel-clickhouse-migrations

Clickhouse migrations for Laravel

102.9k](/packages/alexeykhr-laravel-clickhouse-migrations)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
