icehouse-ventures/laravel-mermaid
Laravel Mermaid generates Mermaid.js diagrams directly from your Laravel app, turning models, relationships, and database schema into clean ER diagrams and flowcharts. Ideal for documentation, code reviews, and onboarding, with simple Artisan commands to render visuals that stay in sync with your co...
Laravel Mermaid 2 targets PHP 8.2+ and Laravel 12 or 13 — verify both before anything else, since this is a hard gate and the main reason an existing install would fail to upgrade.
php artisan vendor:publish, then clear caches: php artisan config:clear && php artisan view:clear.Where to look first: the published config file (rendering mode, strictness, theme), then the Eloquent relationship diagram support and the Blade integration point you'll actually use day to day.
First use case: a dev-only "schema" route that renders an Eloquent relationship diagram (ER diagram) generated from your models. Put it behind app()->isLocal() or an authorization gate from the start — see Gotchas.
Dev-only documentation route. Register the diagram route only in local/staging, or gate it with a policy. The most common pattern is a small controller that returns a view containing one diagram, plus a nav link in your local debug toolbar or an admin-only page.
Eloquent relationship diagrams as generated artifacts. Rather than rendering on every request, generate the Mermaid source in a console command or queued job and cache/commit the output. Model reflection is the expensive part; the browser-side render is not. This also lets you diff schema changes in review.
Multiple diagrams per page. v2 explicitly supports several diagrams on one page. Give each diagram its own container with a unique ID and initialize them independently — reusing IDs is the most common cause of "only the first one renders."
Strict rendering in CI. Turn on strict rendering for tests and CI so malformed Mermaid syntax fails loudly instead of silently producing a blank box. Pair this with a test that asserts each generated diagram parses, which is the cheapest regression net for schema diagrams.
Livewire 4 navigation. Under wire:navigate/Livewire 4 SPA navigation, the page isn't fully reloaded, so DOMContentLoaded-based initialization won't fire on subsequent visits. Hook diagram initialization into the livewire:navigated event (or the equivalent Livewire lifecycle hook) so diagrams re-render after navigation.
Theming and customization. Drive appearance from config rather than inline overrides; override the published views only for layout concerns. Keeping diagram definitions in PHP/config and styling in config makes theme changes a one-line diff.
Static output for docs. If you're publishing architecture docs, render to SVG once and commit it. It keeps Mermaid out of production entirely and gives you stable, reviewable artifacts.
How can I help you explore Laravel packages today?