Download the PHP package zaeem2396/schema-lens without Composer

On this page you can find all versions of the php package zaeem2396/schema-lens. 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 schema-lens

Preview Laravel migrations before execution with destructive change detection

Latest Version Total Downloads License


A Laravel package that extends the default Artisan CLI with commands to preview a single migration file against the current database schema before execution. It provides comprehensive schema diff analysis, destructive change detection, automatic data export, and rollback simulation.

Release highlights: v1.8.0 adds PostgreSQL schema introspection and paired pgsql support for schema:diff. v1.7.0 adds optional full-database backup before safe migrations (migrate:safe --backup), schema-lens.backup configuration, and schema:restore for restore hints. v1.6.0 adds schema:diff across two MySQL connections. Details: CHANGELOG.md.

Features

Quick Start

πŸ“– For detailed usage instructions, testing scenarios, and examples, see USAGE.md

Installation

The package supports:

Schema introspection (schema:preview, migrate:safe, destructive detection, schema:diff) supports MySQL / MariaDB and PostgreSQL using each engine’s catalogs (information_schema and pg_catalog where needed). SQLite and other Laravel drivers cannot run introspection-only flows here; use schema:preview migration.php --sql to inspect generated SQL offline, or run tests against MySQL or PostgreSQL (see CI workflow).

Error output: When a command fails, only the error message is shown by default. Use -v / --verbose to see the full stack trace (e.g. for debugging).

Configuration

Publish the configuration file (optional):

This will create config/schema-lens.php with the following options:

The SQL engine (schema-lens.sql.engine or SCHEMA_LENS_SQL_ENGINE) is used in generated CREATE TABLE statements when using schema:preview --sql. If not set, the default database connection's engine is used (typically InnoDB).

The backup block configures optional logical backups before migrate:safe runs: SCHEMA_LENS_BACKUP_AUTO runs a dump automatically when destructive changes are detected (unless --no-backup), SCHEMA_LENS_BACKUP_DRIVER is mysqldump (default) or spatie (placeholder when spatie/laravel-backup is present), SCHEMA_LENS_BACKUP_DIRECTORY is relative to storage_path(), SCHEMA_LENS_BACKUP_RETENTION_DAYS prunes old schema-lens-db-*.sql files (0 disables pruning), and SCHEMA_LENS_MYSQLDUMP_PATH points to the mysqldump binary if it is not on PATH.

Usage

Basic Usage

Preview a migration file:

Or use a relative path from the migrations directory:

SQL Preview

Generate raw SQL statements that would be executed:

The table engine in generated SQL (e.g. ENGINE=InnoDB) is configurable via config/schema-lens.php β†’ sql.engine or the SCHEMA_LENS_SQL_ENGINE env variable.

Migration Dependency Graph

Visualize which migrations depend on others (e.g. foreign key relationships):

The graph is derived from CREATE TABLE and foreign key operations in each migration. Edges are deduplicated (at most one edge per migration pair). Circular dependencies are detected and reported.

Exit codes: If you pass --path and that directory is empty or contains no migration files, the command exits with code 1. With the default path, an empty directory yields a warning but exit code 0.

Options: --path β€” custom migrations directory; --format=json β€” machine-readable graph. See TESTING-SCENARIOS.md scenario 21 for manual verification steps.

Example output (CLI):

Schema diff between environments

Compare live MySQL schemas from two Laravel database connections (for example local vs staging). Both connections must use the mysql driver and exist in config/database.php.

Exit codes: The command exits with code 1 when any structural difference is found (missing/extra tables or columns, type or nullable mismatches). Use --exit-zero if you only need output in scripts without a failing exit code. It exits 0 when schemas match or when --exit-zero is set.

Example output (CLI):

Example output:

When using --output, the SQL file includes:

JSON Output

Generate a JSON report for CI/CD:

The JSON report will be saved to storage/app/schema-lens/report.json by default.

Skip Data Export

If you want to preview without exporting data (even if destructive changes are detected):

Safe Migration (with auto-backup)

Run migrations with automatic destructive change detection and data backup:

Arguments:

Options:

This command:

  1. Analyzes all pending migrations for destructive changes
  2. Automatically backs up affected data before proceeding
  3. Asks for confirmation if destructive changes are detected
  4. Runs the actual migration

Single Migration File

Run a specific migration file instead of all pending migrations:

This is useful when you:

You can combine it with other options:

The command validates that:

Interactive Mode

For granular control over destructive migrations, use interactive mode:

This prompts you to review each migration with destructive changes individually:

Options during review:

Key Action
y Approve this migration
n Skip this migration
a Approve all remaining migrations
s Skip all remaining migrations
q Quit and cancel everything

Only approved migrations will be executed, giving you full control over which destructive changes to apply.

Full database backup (mysqldump)

In addition to per-table CSV/JSON exports for destructive operations, you can take a full logical backup of the default MySQL database before migrations run:

With SCHEMA_LENS_BACKUP_AUTO=true (or schema-lens.backup.auto), a dump is created automatically when destructive changes are detected, unless you pass --no-backup. --pretend never writes a dump file.

Dumps default to storage_path() + schema-lens.backup.directory, with filenames like schema-lens-db-YYYY-mm-dd_His.sql. Old files matching schema-lens-db-*.sql in that directory are pruned according to retention_days.

Restore hint (schema:restore)

Schema Lens does not execute restores for you. After generating a .sql file (from this package or any mysqldump), print the suggested mysql client invocation:

What It Detects

Schema Changes

Destructive Operations

The following operations are flagged as destructive:

Data Export

When destructive changes are detected, Schema Lens automatically:

  1. Exports affected table/column data to CSV and JSON
  2. Compresses exports (if enabled)
  3. Versions the export with metadata
  4. Creates restore instructions

Export Structure

Restore Metadata

Each export includes a restore_metadata.json file with:

Output Examples

CLI Output

JSON Output

Rollback Simulation

Schema Lens analyzes the down() method of migrations to:

Requirements

Environment Variables

You can configure Schema Lens using environment variables:

CI/CD Integration

GitHub Actions Example

GitLab CI Example

Troubleshooting

Limitations

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This package is open-sourced software licensed under the MIT license.

Author

zaeem2396

GitHub: @zaeem2396

Support

For issues, questions, or contributions, please open an issue on GitHub.


All versions of schema-lens with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/filesystem Version ^10.0|^11.0|^12.0|^13.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 zaeem2396/schema-lens contains the following files

Loading the files please wait ...