A Laravel package for generating Entity-Relationship Diagrams (ERD) of your database schema. This tool is designed to support multiple database systems like MySQL, PostgreSQL, SQLite, SQL Server, and Oracle.
- Automatically scans your database schema for tables and their relationships.
- Generates ERD diagrams in PDF format using Graphviz.
- Extensible design with support for multiple database drivers.
- PHP 8.1 or higher
- Laravel 9.x or higher
- Graphviz installed on your system
composer require rtcoder/laravel-db-erd
If you need to customize the behavior, publish the configuration file:
php artisan vendor:publish --tag=db-erd-config
If you need to customize the views, you can publish them using:
php artisan vendor:publish --tag=db-erd-views
This will copy the default views to your project's resources/views/vendor/laravel-erd
directory, where you can modify them as needed.
Ensure Graphviz is installed on your system.
brew install graphviz
sudo apt install graphviz
Download and install from Graphviz's official site.
Generate an ERD Run the following Artisan command to generate the ERD:
php artisan erd:generate --output=storage/erd/erd_diagram.pdf --driver=mysql
The --output
option specifies the file path for the generated diagram.
Supported Databases
- MySQL
- PostgreSQL
- SQLite
- SQL Server
- Oracle
Supported output formats
- SVG
- PNG
- HTML
You can customize the package by modifying the configuration file (config/db-erd.php
):
return [
'default_driver' => env('DB_ERD_DRIVER', 'mysql'),
'output_directory' => storage_path('erd'),
'output_name' => 'erd_diagram',
'output_format' => 'pdf',
'exclude_tables' => ['migrations', 'jobs', 'failed_jobs'],
];
-
Graphviz not found
Error
Ensure Graphviz is correctly installed and added to your system's PATH. -
Empty ERD Diagram
Verify that your database schema has relationships (foreign keys).
This package is open-source software licensed under the MIT license.