dgtlss/easyerd
Generate ERDs for Laravel apps from models and migrations. Create diagrams as PDF/PNG/SVG/JPG plus a text ERD. Configure output paths, table/relationship styling, exclusions, dark mode, and high-res Graphviz layouts via an Artisan command.
Install the package via Composer:
composer require your-vendor/easy-erd
Publish the configuration file (if needed) and service provider:
php artisan vendor:publish --provider="YourVendor\EasyErd\EasyErdServiceProvider"
Generate your first ERD diagram for a model (e.g., User) in a controller or command:
use YourVendor\EasyErd\ErdGenerator;
public function generateErd()
{
$erd = new ErdGenerator();
$diagram = $erd->generate('App\Models\User');
return response()->streamDownload(function () use ($diagram) {
echo $diagram->toPng();
}, 'user_erd.png');
}
Key files to review:
config/easy-erd.php (for customization)app/Console/Commands/GenerateErdCommand.php (pre-built CLI command)ErdGenerator class in controllers, commands, or API routes to generate diagrams dynamically.
$erd = (new ErdGenerator())->generate(['App\Models\User', 'App\Models\Post']);
GenerateErdCommand for cron jobs or automated documentation:
php artisan erd:generate --models="User,Post" --output="storage/app/erds"
{!! (new \YourVendor\EasyErd\ErdGenerator())->generate('App\Models\User')->toSvg() !!}
$diagram = Cache::remember("erd_{$model}", now()->addHours(1), fn() =>
(new ErdGenerator())->generate($model)
);
'graphviz' => [
'rankdir' => 'LR', // Left-to-right layout
'node' => [
'shape' => 'box3d',
'fontname' => 'Arial',
],
],
$erd->generate('App\Models\*'); // All models in the namespace
graphviz is installed on your server. The package checks for this on generation but may fail silently in production if missing. Test locally with:
dot -V
memory_limit in php.ini or generate diagrams in chunks.--depth option to limit recursion:
php artisan erd:generate --models="User" --depth=2
'debug' => env('EASY_ERD_DEBUG', false),
YourVendor\EasyErd\Contracts\ErdGenerator to support custom diagram types (e.g., plantuml).generate() method to preprocess models or postprocess the DOT language output.ErdStorage implementation.$this->app->bind(\YourVendor\EasyErd\Contracts\ErdStorage::class, function () {
return new \YourVendor\EasyErd\Storage\S3Storage();
});
How can I help you explore Laravel packages today?