jawira/entity-draw
Entity Draw is a PHP package for generating entity-relationship diagrams from your code. Visualize models and database structures, export diagrams for documentation, and keep architecture clear with a simple, PlantUML-friendly workflow.
jawira/entity-draw is a standalone CLI static-analysis tool, not a Laravel package: it scans PHP source and emits class/entity diagrams (primarily PlantUML). There is no service provider, no config/entity-draw.php, and no facade — you drive it from the shell or a Composer script.
composer require --dev jawira/entity-draw:^2.0
vendor/bin/entity-draw --help
vendor/bin/entity-draw list # available writers/formats
Then read the README section on filters (the v2 addition) and the jawira/contracts v2 docs for writer/output behaviour.vendor/bin/entity-draw app/Models -o build/erd.puml
plantuml -tsvg build/erd.puml) or via the PlantUML server — but only for non-proprietary code.Add a Composer script immediately so the command is discoverable and consistent across the team:
"scripts": {
"diagrams": "entity-draw app/Models app/Domain -o build/erd.puml"
}
Scope by directory, refine with filters. The realistic workflow is one diagram per bounded context, not one diagram for app/. Point the tool at app/Domain/Sales, app/Models, etc., and use the v2 include filters to trim noise (framework base classes, traits, DTOs) rather than post-editing the .puml.
Composer script as the single entry point. Wrap the invocation in a script (or several: diagrams:models, diagrams:domain) so CI, docs builds, and developers all run the identical command with identical flags. Never document raw ad-hoc invocations in the README — they drift.
CI artifact generation. Run the script in a CI job and upload the .puml/.svg as a build artifact, or publish to a docs site. Keep the rendering step separate: the tool produces text, PlantUML (Java) or a container image renders it. Use the official PlantUML Docker image rather than installing Java on the runner.
- run: composer diagrams
- run: docker run --rm -v $PWD/build:/data plantuml/plantuml -tsvg /data/erd.puml
Pair it with a hand-written architecture doc. Auto-generated class diagrams are excellent for spotting accidental coupling and orphaned classes; they are poor at communicating intent. Generate them, commit or publish them, and narrate them in prose.
Custom Artisan wrapper (optional). If you want php artisan diagrams, write a thin command that shells out with Symfony\Component\Process\Process and the same flags. This is the correct integration point — do not expect first-party Laravel support.
Diff-friendly output. Generate into a dedicated build/ or docs/diagrams/ directory, and treat the output as a generated artifact. If you commit it, add a .gitattributes entry or reviewer convention so ordering churn doesn't dominate PR diffs.
jawira/contracts v2. If another Jawira tool in your require-dev still pins contracts v1 (e.g. a PlantUML client), Composer will refuse to resolve both. Check with composer why jawira/contracts before upgrading, and be prepared to upgrade sibling packages in the same PR.^2.0 — a * or dev constraint here will silently break your CI diagram job on the next major.$this->hasMany(...) returning untyped properties), morphTo, model attributes, and anything resolved at runtime will not appear as associations. You get classes, methods, and declared types — set expectations accordingly, and don't try to make it an ERD generator for your schema (use doctrine/dbal / schema:dump for that).app/ produces an unreadable hairball. Always scope to a directory + namespace/include filter. If the diagram is unreadable, the fix is a narrower input path, not a bigger canvas.mkdir -p build in the script rather than relying on the tool.jawira/contracts v2. Custom output formats/templates are done by implementing the contracts and invoking the tool with your writer, not by hooking into Laravel. Check list output for available writers before writing one.How can I help you explore Laravel packages today?