If you are working on a project which have lot of Models and Relationship complexities and you thinking about how easy it would be if you had an ER diagram to understand the complexities of the database structure.
BeyondCode has introduced a very cool Laravel package which will generate ER diagram for your existing project Models, and with ease.
Here is how you can generate ER Diagram with laravel-er-diagram-generator package.
Requirements
This package is dependent on GraphViz to generate the ER diagram, Thus first we will install this dependency.
sudo apt-get install graphviz
Use coupon 5balloons on this Cloudways Affiliate URL to get special discount.
Installation
You can install this package via composer
composer require beyondcode/laravel-er-diagram-generator --dev
If you are using Laravel 5.5+, the package will automatically register the service provider for you.
Generating ER Diagram
By default, the package will automatically detect all models in your app
directory that extend the Eloquent Model class. If you would like you explicitly define where your models are located, you can publish the configuration file using the following command.
php artisan vendor:publish --provider=BeyondCode\\ErdGenerator\\ErdGeneratorServiceProvider
That’s it run the following command to generate ER diagrams.
php artisan generate:erd
ER diagram image file will be saved as graph.png on your project root.