›
byrcsc/laravel-cartographer · 1.x
Laravel Cartographer generates a diagram from your Eloquent models and database schema.
A migration changes your database, but it does not update the diagram your team uses to understand it. Over time, that diagram stops matching the application.
Laravel Cartographer generates a Mermaid entity relationship diagram from an existing Laravel application. Run one Artisan command:
php artisan cartographer:erdThe command writes docs/erd.md. GitHub and GitLab render the file as a
diagram:
erDiagram
posts }o--|| categories : "category"
posts ||--o{ comments : "comments"
posts }o--o{ tags : "tags"
posts }o--|| users : "author"
posts {
bigint author_id FK
text body "nullable"
bigint category_id FK "nullable"
bigint id PK
varchar title
}Commit the generated file with the migration. The pull request then shows the database change and the updated diagram together.
Cartographer combines information from your models and your database.
Your Eloquent models provide the relationships. For example, an author()
relation becomes an edge labelled author.
Your database provides the tables, columns, and keys. Cartographer reads the current schema instead of rebuilding it from old migration files.
The package never reads rows from your tables. It reads schema information and builds Eloquent relation objects without running relation queries.
The default command creates a Markdown file containing Mermaid syntax. You can also:
The detailed options live in the operations and reference pages. The quick start uses the default path first.
| Requirement | Supported versions |
|---|---|
| PHP | 8.3, 8.4 |
| Laravel | 12.x, 13.x |
| Databases | MySQL, PostgreSQL, SQLite |
The package follows semantic versioning. You can upgrade within 1.x without
breaking changes.
Source code and issues are available on GitHub.