Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Easyerd Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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)

Implementation Patterns

Core Workflow

  1. On-Demand Generation: Use the ErdGenerator class in controllers, commands, or API routes to generate diagrams dynamically.
    $erd = (new ErdGenerator())->generate(['App\Models\User', 'App\Models\Post']);
    
  2. Scheduled Diagrams: Leverage the built-in GenerateErdCommand for cron jobs or automated documentation:
    php artisan erd:generate --models="User,Post" --output="storage/app/erds"
    
  3. Embedding in Views: Output SVG directly in Blade templates:
    {!! (new \YourVendor\EasyErd\ErdGenerator())->generate('App\Models\User')->toSvg() !!}
    

Integration Tips

  • Cache Diagrams: Cache generated diagrams to avoid reprocessing:
    $diagram = Cache::remember("erd_{$model}", now()->addHours(1), fn() =>
        (new ErdGenerator())->generate($model)
    );
    
  • Custom Styling: Override default Graphviz attributes via config:
    'graphviz' => [
        'rankdir' => 'LR', // Left-to-right layout
        'node' => [
            'shape' => 'box3d',
            'fontname' => 'Arial',
        ],
    ],
    
  • Multi-Model Diagrams: Pass an array of models or use wildcards:
    $erd->generate('App\Models\*'); // All models in the namespace
    

Gotchas and Tips

Pitfalls

  • Graphviz Dependencies: Ensure 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 Limits: Complex schemas may hit PHP’s memory limit. Increase memory_limit in php.ini or generate diagrams in chunks.
  • Model Relationships: One-to-many/polymorphic relationships may produce cluttered diagrams. Use the --depth option to limit recursion:
    php artisan erd:generate --models="User" --depth=2
    

Debugging

  • Verbose Output: Enable debug mode in config to log Graphviz commands:
    'debug' => env('EASY_ERD_DEBUG', false),
    
  • Fallback Formats: If Graphviz fails, the package defaults to a text-based representation. Check logs for errors.

Extension Points

  • Custom Generators: Extend YourVendor\EasyErd\Contracts\ErdGenerator to support custom diagram types (e.g., plantuml).
  • Hooks: Override the generate() method to preprocess models or postprocess the DOT language output.
  • Storage Adapters: Replace the default file storage with S3 or database storage by binding a custom ErdStorage implementation.
$this->app->bind(\YourVendor\EasyErd\Contracts\ErdStorage::class, function () {
    return new \YourVendor\EasyErd\Storage\S3Storage();
});
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity