Download the PHP package malikad778/laravel-migration-guard without Composer

On this page you can find all versions of the php package malikad778/laravel-migration-guard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-migration-guard

# ๐Ÿ›ก๏ธ laravel-migration-guard **Catch dangerous database migrations before they reach production.** The `strong_migrations` equivalent for Laravel. Static analysis. Zero configuration. Framework-native. [![Tests](https://img.shields.io/github/actions/workflow/status/malikad778/Laravel-migration-guard/tests.yml?branch=main&label=tests&style=flat-square&logo=github)](https://github.com/malikad778/Laravel-migration-guard/actions/workflows/tests.yml) [![PHP Version](https://img.shields.io/badge/PHP-8.2%2B-8892BF?style=flat-square&logo=php&logoColor=white)](https://php.net) [![Laravel](https://img.shields.io/badge/Laravel-10%20|%2011%20|%2012-FF2D20?style=flat-square&logo=laravel&logoColor=white)](https://laravel.com) [![Latest Version on Packagist](https://img.shields.io/packagist/v/malikad778/laravel-migration-guard?style=flat-square&logo=packagist&logoColor=white)](https://packagist.org/packages/malikad778/laravel-migration-guard) [![Total Downloads](https://img.shields.io/packagist/dt/malikad778/laravel-migration-guard?style=flat-square&logo=packagist&logoColor=white&color=4CAF50)](https://packagist.org/packages/malikad778/laravel-migration-guard) [![License](https://img.shields.io/github/license/malikad778/Laravel-migration-guard?style=flat-square&color=16A085)](LICENSE.md) [![Stars](https://img.shields.io/github/stars/malikad778/Laravel-migration-guard?style=flat-square&logo=github&color=f1c40f)](https://github.com/malikad778/Laravel-migration-guard/stargazers) [![Issues](https://img.shields.io/github/issues/malikad778/Laravel-migration-guard?style=flat-square&logo=github)](https://github.com/malikad778/Laravel-migration-guard/issues) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen?style=flat-square)](https://github.com/malikad778/Laravel-migration-guard/pulls) [![Pest](https://img.shields.io/badge/tested%20with-Pest-A259FF?style=flat-square&logo=pestphp&logoColor=white)](https://pestphp.com)

Demo

The Problem

Every Laravel team doing zero-downtime deployments has eventually had a migration incident. These operations succeed without errors in development, then cause production outages anywhere from immediately to hours later:

Operation What breaks in production
dropColumn() Old app instances still query the dropped column โ€” immediate DB errors during the deployment window
NOT NULL without default Full table rewrite on MySQL < 8.0 โ€” locks reads and writes for minutes on large tables
renameColumn() Old instances use old name, new instances use new name โ€” one of them is always wrong
addIndex() without INPLACE MySQL < 8.0 holds a full write lock while building the index โ€” minutes on busy tables
change() column type Full table rewrite, potential silent data truncation (e.g. VARCHAR(50) โ†’ VARCHAR(40))
Schema::rename() Every Eloquent model and raw query referencing the old table name breaks immediately
truncate() in a migration Production data permanently destroyed โ€” migrations are the wrong place for data deletion

Rails developers have had strong_migrations (4,000+ GitHub stars) for years. The Laravel ecosystem has no maintained equivalent. Every team solves this by hand: code review checklists, tribal knowledge, and hoping nobody forgets to check.

laravel-migration-guard eliminates that risk by making artisan migrate production-aware โ€” without changing your workflow.


Installation

The package auto-discovers via Laravel's package discovery. No manual registration required.

Optionally publish the config file:

That's it. Out of the box, with zero configuration, the guard:


How It Works

The package uses static analysis โ€” it parses your migration PHP files into an Abstract Syntax Tree (AST) using nikic/php-parser and walks the tree looking for dangerous method call patterns.

This means:

Analysis Pipeline


Safety Checks

Nine checks are included. All enabled by default, individually configurable.

Check ID Severity What It Detects
drop_column ๐Ÿ”ด BREAKING dropColumn() or dropColumns() on an existing table
drop_table ๐Ÿ”ด BREAKING Schema::drop() or Schema::dropIfExists()
rename_column ๐Ÿ”ด BREAKING renameColumn() on any table
rename_table ๐Ÿ”ด BREAKING Schema::rename()
modify_primary_key ๐Ÿ”ด BREAKING dropPrimary() or primary() on an existing table
truncate ๐Ÿ”ด BREAKING DB::table()->truncate() inside a migration
add_column_not_null ๐ŸŸก HIGH Column added without ->nullable() or ->default()
change_column_type ๐ŸŸก HIGH ->change() modifying an existing column type
add_index ๐Ÿ”ต MEDIUM Index added to a critical or large table

Check Details & Safe Alternatives

Drop Column โ€” BREAKING

Why: During a zero-downtime deployment, old app instances run alongside the new schema. Any query touching the dropped column fails immediately with a database error.

Safe approach:

  1. Deploy 1: Remove all code references to the column (models, queries, $fillable, $casts)
  2. Deploy 2: Drop the column after confirming no running instance references it

Add NOT NULL Column Without Default โ€” HIGH

Why: MySQL < 8.0 requires a full table rewrite when adding a NOT NULL column without a default. On a large table this blocks all reads and writes for minutes.

Safe approach:

  1. Add the column as ->nullable() (instant, no lock)
  2. Backfill existing rows: User::whereNull('status')->update(['status' => 'active'])
  3. Add the NOT NULL constraint in a separate migration after backfill completes

Rename Column / Table โ€” BREAKING

Why: Old instances use the old name, new instances use the new name โ€” one is always wrong during the deployment window. Eloquent models, raw queries, and $fillable arrays all break.

Safe approach: Add new column โ†’ copy data โ†’ update code โ†’ deploy โ†’ drop old column in a follow-up migration.


Add Index (on critical/large tables) โ€” MEDIUM

Why: MySQL < 8.0 holds a full write lock while building an index. MySQL 8.0+ and PostgreSQL support online index builds but require specific syntax that Laravel migrations do not use by default.


Change Column Type โ€” HIGH

Why: A full table rewrite is required in most databases. Implicit type coercions can silently corrupt data (e.g. VARCHAR(255) โ†’ VARCHAR(100) truncates existing values). Indexes on the column may be dropped.

Safe approach: Add new column of the correct type โ†’ migrate data โ†’ update code โ†’ deploy โ†’ drop old column.


Example Warning Output


Configuration

Environment Variable Overrides

Variable Description
MIGRATION_GUARD_MODE warn or block. Overrides config file.
MIGRATION_GUARD_DISABLE Set to true to disable entirely (e.g. in CI seed steps).
MIGRATION_GUARD_ROW_THRESHOLD Row count above which a table is treated as critical for index checks. Default: 500000.

Artisan Commands

php artisan migration:guard:analyse

Standalone command for CI/CD pipelines. Analyses all pending migrations and outputs a report without running them. Exits with code 1 if dangerous operations are found.

Exit codes:

Code Meaning
0 No issues found, or all issues below --fail-on threshold
1 One or more issues at or above threshold
2 Analysis error (parse failure, permission error)

php artisan migration:guard:ignore

Adds a suppression entry to config/migration-guard.php for a specific check and table โ€” or check, table, and column.

Valid check IDs: drop_column, drop_table, rename_column, rename_table, add_column_not_null, change_column_type, add_index, modify_primary_key, truncate


JSON Output Schema


CI/CD Integration

GitHub Actions

The --format=github flag produces GitHub Actions annotation syntax, placing inline warnings directly on the pull request diff at the relevant migration file line.


GitLab CI


Package Architecture


Requirements

Version
PHP 8.2 or higher
Laravel 10.x, 11.x, 12.x
MySQL 5.7+ or 8.0+
PostgreSQL 13+
SQLite 3+
nikic/php-parser ^5.0 (installed automatically)

Comparison: strong_migrations vs laravel-migration-guard

Feature strong_migrations laravel-migration-guard
Drop column detection โœ… โœ…
Drop table detection โœ… โœ…
Rename detection โœ… โœ…
NOT NULL without default โœ… โœ…
Index safety โœ… โœ…
CI/CD JSON output โœ… โœ…
GitHub Annotations โŒ โœ…
Per-table suppression โœ… โœ…
Per-column suppression โŒ โœ…
Warn vs Block mode โœ… โœ…
Zero config defaults โœ… โœ…
Framework Rails only Laravel only

Roadmap

v1.0.0 โ€” Launch (current)

v1.1.0 โ€” Database Awareness

v1.2.0 โ€” Reporting

v2.0.0 โ€” Safe Alternative Code Generation


Contributing

Contributions are welcome. Adding a new check requires only:

  1. Create a class implementing CheckInterface in src/Checks/
  2. Register it in MigrationGuardServiceProvider::register()
  3. Add the check ID to the checks array in config/migration-guard.php
  4. Write unit tests covering both the unsafe pattern and the safe equivalent (false positive tests are required)

License

MIT โ€” free forever. See LICENSE.md.


Made for the Laravel ecosystem ยท Inspired by [`strong_migrations`](https://github.com/ankane/strong_migrations) **[Report a Bug](https://github.com/malikad778/laravel-migration-guard/issues) ยท [Request a Feature](https://github.com/malikad778/laravel-migration-guard/issues) ยท [Sponsor](https://github.com/sponsors/malikad778)**

All versions of laravel-migration-guard with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/console Version ^10.0|^11.0|^12.0
illuminate/events Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/notifications Version ^10.0|^11.0|^12.0
nikic/php-parser Version ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package malikad778/laravel-migration-guard contains the following files

Loading the files please wait ...