farzai / laravel-schema
Visualize and compare database schemas between Laravel migrations and your database
Fund package maintenance!
parsilver
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/farzai/laravel-schema
Requires
- php: ^8.4
- illuminate/contracts: ^11.0||^12.0
- nikic/php-parser: ^5.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
This package is auto-updated.
Last update: 2026-01-14 14:46:03 UTC
README
A Laravel package for visualizing and comparing database schemas. View your database structure through an interactive ER diagram dashboard and identify differences between your migration files and actual database state.
Similar to Laravel Horizon and Telescope, it provides a beautiful web interface for schema inspection. This package is view-only — it detects and visualizes differences but does not generate or apply migrations.
Features
- Interactive ER Diagram — Visualize your database schema with React Flow
- Schema Comparison — Compare migrations vs actual database state
- Multi-Database Support — MySQL, PostgreSQL, SQLite, and SQL Server
- Diff Detection — See added, removed, and modified tables/columns at a glance
- REST API — Programmatic access to schema data
- Gate-based Authorization — Secure access similar to Horizon/Telescope
- Dark Mode — Beautiful dark theme out of the box
Requirements
- PHP 8.4+
- Laravel 11.x or 12.x
Installation
Install the package via Composer:
composer require farzai/laravel-schema
Publish the configuration file:
php artisan vendor:publish --tag=laravel-schema-config
Publish the frontend assets:
php artisan vendor:publish --tag=laravel-schema-assets
Configuration
The configuration file will be published to config/schema.php:
return [ // Subdomain for Laravel Schema (optional) 'domain' => env('SCHEMA_DOMAIN'), // URI path where the dashboard is accessible 'path' => env('SCHEMA_PATH', 'schema'), // Route middleware 'middleware' => ['web'], // Authorization settings 'authorization' => [ 'enabled' => true, 'gate' => 'viewLaravelSchema', ], // Path to migrations directory 'migrations_path' => 'database/migrations', // Database connection (null = default) 'connection' => null, // Tables to ignore during comparison 'ignored_tables' => [ 'migrations', 'password_reset_tokens', 'sessions', 'cache', 'cache_locks', 'jobs', 'job_batches', 'failed_jobs', ], ];
Authorization
By default, Laravel Schema is only accessible in the local environment. To configure access in other environments, define authorization logic in your AppServiceProvider:
use Farzai\LaravelSchema\SchemaInspector; public function boot(): void { SchemaInspector::auth(function ($request) { return app()->environment('local') || in_array($request->user()?->email, [ 'admin@example.com', ]); }); }
Dashboard
Once installed, access the dashboard at:
http://your-app.test/schema
The dashboard provides:
- ER Diagram — Interactive visualization of your database tables and relationships
- Schema Differences — Visual indicators for added, removed, and modified schema elements
- Table Details — Column types, indexes, and foreign key information
- Legend — Color-coded guide for understanding diff status
API Endpoints
Laravel Schema exposes a REST API for programmatic access:
| Method | Endpoint | Description |
|---|---|---|
| GET | /schema |
Dashboard (React SPA) |
| GET | /schema/api/tables |
List all database tables |
| GET | /schema/api/tables/{table} |
Get specific table details |
| GET | /schema/api/diff |
Full schema comparison |
| GET | /schema/api/diff/{table} |
Table-specific diff |
| GET | /schema/api/migrations |
List migration files |
| GET | /schema/api/status |
Schema sync status summary |
| POST | /schema/api/refresh |
Force schema refresh |
Testing
composer test
Run tests with coverage:
composer test-coverage
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
