PHPackages                             paolobellini/laravel-er - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. paolobellini/laravel-er

ActiveLibrary[Database &amp; ORM](/categories/database)

paolobellini/laravel-er
=======================

Automatically generate ER diagrams and AI-ready schema documentation from your Laravel database and Eloquent models.

v1.0.1(1w ago)13[5 issues](https://github.com/paolobellini/laravel-er/issues)MITPHPPHP ^8.2CI passing

Since Mar 6Pushed 1w agoCompare

[ Source](https://github.com/paolobellini/laravel-er)[ Packagist](https://packagist.org/packages/paolobellini/laravel-er)[ Docs](https://github.com/paolobellini/laravel-er)[ RSS](/packages/paolobellini-laravel-er/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (8)Versions (5)Used By (0)

Laravel ER
==========

[](#laravel-er)

Automatically generate ER diagrams from your Laravel database schema. One command, zero configuration required.

```
php artisan er:generate
```

Why?
----

[](#why)

**Give AI agents full context of your database.** Drop the generated `er-diagram.md` into your project root and every AI coding assistant (Claude Code, Cursor, GitHub Copilot, ...) instantly understands your tables, columns, types, relationships, and constraints. No more explaining your schema by hand in every prompt.

But that's not all. The same file works as:

- **Living documentation** that stays in sync with your actual database, versioned alongside your code.
- **Visual diagrams** that render natively on GitHub, GitLab, and Notion, so your team can understand complex schemas at a glance.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12

Installation
------------

[](#installation)

```
composer require paolobellini/laravel-er --dev
```

The service provider is auto-discovered. No manual registration needed.

Configuration
-------------

[](#configuration)

Optionally publish the config file to customize the behavior:

```
php artisan vendor:publish --tag=er-config
```

This creates `config/er.php` with the following options:

```
return [
    // Where the generated file will be saved
    'output_path' => base_path(),

    // The filename (without extension)
    'output_filename' => 'er-diagram',

    // Tables to exclude from the diagram
    'excluded_tables' => [
        'migrations',
        'failed_jobs',
        'password_reset_tokens',
        'sessions',
        'cache',
        'cache_locks',
        'jobs',
        'job_batches',
    ],

    // Default renderer
    'renderer' => 'mermaid',

    // Available renderers
    'renderers' => [
        'mermaid' => MermaidRenderer::class,
        'dbdiagram' => DbDiagramRenderer::class,
    ],
];
```

Usage
-----

[](#usage)

### Generate with the default renderer (Mermaid)

[](#generate-with-the-default-renderer-mermaid)

```
php artisan er:generate
```

### Choose a specific format

[](#choose-a-specific-format)

```
php artisan er:generate --format=mermaid
php artisan er:generate --format=dbdiagram
```

### Output

[](#output)

The diagram is saved to `er-diagram.md` in your project root by default.

Supported Formats
-----------------

[](#supported-formats)

### Mermaid

[](#mermaid)

Generates a [Mermaid](https://mermaid.js.org/) ER diagram wrapped in a fenced code block. Renders natively on GitHub, GitLab, Notion, and many other platforms.

 ```
erDiagram
    users {
        integer id PK "not null"
        varchar name "not null"
        varchar email UK "not null"
        timestamp created_at "nullable"
    }
    posts {
        integer id PK "not null"
        integer user_id FK "not null"
        varchar title "not null"
        varchar status "not null, default: draft"
    }
    users ||--o{ posts : "has many"
```

      Loading ### dbdiagram

[](#dbdiagram)

Generates a [dbdiagram.io](https://dbdiagram.io/) compatible schema. Copy and paste the output into dbdiagram.io to get an interactive visual diagram.

```
Table users {
  id integer [primary key, not null]
  name varchar(255) [not null]
  email varchar(255) [not null, unique]
  created_at timestamp [null]
}
Table posts {
  id integer [primary key, not null]
  user_id integer [not null]
  title varchar(255) [not null]
  status varchar [not null, default: 'draft']
}
Ref: posts.user_id > users.id

```

Column Details
--------------

[](#column-details)

The generated diagrams include rich column metadata:

DetailMermaiddbdiagramPrimary key`PK` marker`primary key` attributeForeign key`FK` marker + relationship line`Ref:` statementUnique`UK` marker`unique` attributeNullable`nullable` / `not null` in comment`null` / `not null` attributeDefault value`default: value` in comment`default: 'value'` attributeType details`(255)`, `unsigned`, `values: ...` in commentFull type preservedRelationship Detection
----------------------

[](#relationship-detection)

Relationships are automatically inferred from foreign keys:

ScenarioMermaiddbdiagramFK without unique index`||--o{` (one-to-many)`>` (many-to-one)FK with unique index`||--||` (one-to-one)`-` (one-to-one)Nullable FK`o|--` (zero-or-one)`>` / `-`Testing
-------

[](#testing)

```
composer test
```

This runs the full test suite: linting, type coverage, unit tests, static analysis, and refactoring checks.

Contributing
------------

[](#contributing)

Contributions are welcome! Please read the [contributing guide](CONTRIBUTING.md) to get started.

Credits
-------

[](#credits)

- [Paolo Bellini](https://bellini.one)
- [All Contributors](https://github.com/paolobellini/laravel-er/graphs/contributors)

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

37

—

LowBetter than 84% of packages

Maintenance78

Regular maintenance activity

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

2

Last Release

11d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3fb74719ea556a2d0a90616a9894da74e9f62f85cd9e4120b01651e02ede58f4?d=identicon)[paolobellini](/maintainers/paolobellini)

---

Top Contributors

[![paolobellini](https://avatars.githubusercontent.com/u/112547894?v=4)](https://github.com/paolobellini "paolobellini (39 commits)")

---

Tags

laravelschemadatabasedocumentationmermaider diagramdbdiagramai-context

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/paolobellini-laravel-er/health.svg)

```
[![Health](https://phpackages.com/badges/paolobellini-laravel-er/health.svg)](https://phpackages.com/packages/paolobellini-laravel-er)
```

###  Alternatives

[stolz/laravel-schema-spy

Laravel artisan command that uses JAVA schemaSpy tool to generate a graphical representation of a database schema

4521.8k](/packages/stolz-laravel-schema-spy)[devio/eavquent

EAV modeling package for Eloquent and Laravel.

6410.4k](/packages/devio-eavquent)[dragon-code/laravel-data-dumper

Adding data from certain tables when executing the `php artisan schema:dump` console command

3417.3k](/packages/dragon-code-laravel-data-dumper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
