PHPackages                             beyondcode/laravel-er-diagram-generator - 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. beyondcode/laravel-er-diagram-generator

ActiveLibrary

beyondcode/laravel-er-diagram-generator
=======================================

Generate ER diagrams from your Laravel models.

6.0.0(1mo ago)2.0k1.4M—5.1%203[13 issues](https://github.com/beyondcode/laravel-er-diagram-generator/issues)2MITPHPPHP ^8.2CI passing

Since Jul 3Pushed 1mo ago32 watchersCompare

[ Source](https://github.com/beyondcode/laravel-er-diagram-generator)[ Packagist](https://packagist.org/packages/beyondcode/laravel-er-diagram-generator)[ Docs](https://github.com/beyondcode/laravel-er-diagram-generator)[ RSS](/packages/beyondcode-laravel-er-diagram-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (24)Used By (2)

Laravel ER Diagram Generator
============================

[](#laravel-er-diagram-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b4131b70cd90a610a566da7c5c3727367445a3bcb5db95e9ab5fc893b17d3d55/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6265796f6e64636f64652f6c61726176656c2d65722d6469616772616d2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beyondcode/laravel-er-diagram-generator)[![Total Downloads](https://camo.githubusercontent.com/e354c5896a40b528a61489a83de2e877f3bd941f49ca89993b18ecf276d51c4a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6265796f6e64636f64652f6c61726176656c2d65722d6469616772616d2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beyondcode/laravel-er-diagram-generator)

This package lets you generate entity relation diagrams by inspecting the relationships defined in your model files. It is highly customizable. Behind the scenes, it uses [GraphViz](https://www.graphviz.org) to generate the graph.

> If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming [PHP Package Development](https://phppackagedevelopment.com) video course.

Prerequisites
-------------

[](#prerequisites)

The minimum required PHP version is 7.1.0.

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

[](#requirements)

This package requires the `graphviz` tool.

You can install Graphviz on MacOS via homebrew:

```
brew install graphviz
```

Or, if you are using Homestead:

```
sudo apt-get install graphviz
```

To install Graphviz on Windows, download it from the [official website](https://graphviz.gitlab.io/_pages/Download/Download_windows.html).

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

[](#installation)

You can install the package via composer:

```
composer require beyondcode/laravel-er-diagram-generator --dev
```

If you are using Laravel 5.5+, the package will automatically register the service provider for you.

If you are using Lumen, you will need to add the following to `bootstrap\app.php`:

```
# Register Service Providers
$app->register(BeyondCode\ErdGenerator\ErdGeneratorServiceProvider::class);
```

Usage
-----

[](#usage)

By default, the package will automatically detect all models in your `app/Models` directory that extend the Eloquent Model class. If you would like you explicitly define where your models are located, you can publish the configuration file using the following command.

```
php artisan vendor:publish --provider=BeyondCode\\ErdGenerator\\ErdGeneratorServiceProvider
```

If you're using Lumen and you want to customize the config, you'll need to copy the config file from the vendor directory:

```
cp ./vendor/beyondcode/laravel-er-diagram-generator/config/config.php config/erd-generator.php
```

Generating Diagrams
-------------------

[](#generating-diagrams)

You can generate entity relation diagrams using the provided artisan command:

```
php artisan generate:erd
```

This will generate a file called `graph.png`.

You can also specify a custom filename:

```
php artisan generate:erd output.png
```

Or use one of the other [output formats](https://www.graphviz.org/doc/info/output.html), like SVG:

```
php artisan generate:erd output.svg --format=svg
```

### Text Output

[](#text-output)

If you want to generate a text representation of the ER diagram instead of an image, you can use the `--text-output` option:

```
php artisan generate:erd output.txt --text-output
```

This will generate a text file with the GraphViz DOT representation of the ER diagram.

### Structured Text Output for AI Models

[](#structured-text-output-for-ai-models)

If you want to generate a structured text representation of the ER diagram that is more suitable for AI models, simply specify a filename with a `.txt` extension:

```
php artisan generate:erd output.txt
```

This will automatically generate a Markdown file with a structured representation of the entities and their relationships, which can be used as context for AI models.

#### Output Format

[](#output-format)

The structured output format looks like this:

```
# Entity Relationship Diagram

## Entities

### User (`App\Models\User`)

#### Attributes:
- `id` (integer)
- `name` (string)
- `email` (string)
...

## Relationships

### User Relationships
- **HasMany** `posts` to Post (Local Key: `id`, Foreign Key: `user_id`)
...
```

This format is particularly useful when providing context to AI models about your database structure.

Customization
-------------

[](#customization)

Please take a look at the published `erd-generator.php` configuration file for all available customization options.

Examples
--------

[](#examples)

Here are some examples taken from the [Laravel.io](https://laravel.io) codebase.

[![Using Database Schema](https://camo.githubusercontent.com/f031f555abbcc3e745f74b9a7f77e1ea6972103fe6ac52f838c40cbdcb6c5d1a/68747470733a2f2f6265796f6e64636f2e64652f6769746875622f6572642d67656e657261746f722f736368656d612e706e67)](https://camo.githubusercontent.com/f031f555abbcc3e745f74b9a7f77e1ea6972103fe6ac52f838c40cbdcb6c5d1a/68747470733a2f2f6265796f6e64636f2e64652f6769746875622f6572642d67656e657261746f722f736368656d612e706e67)

[![Customized](https://camo.githubusercontent.com/dbbc243b54022f30a5eebd726e513c55cdd721f3ec8fcd193d9fb6f94851de56/68747470733a2f2f6265796f6e64636f2e64652f6769746875622f6572642d67656e657261746f722f637573746f6d697a65642e706e67)](https://camo.githubusercontent.com/dbbc243b54022f30a5eebd726e513c55cdd721f3ec8fcd193d9fb6f94851de56/68747470733a2f2f6265796f6e64636f2e64652f6769746875622f6572642d67656e657261746f722f637573746f6d697a65642e706e67)

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Marcel Pociot](https://github.com/mpociot)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

73

—

ExcellentBetter than 100% of packages

Maintenance89

Actively maintained with recent releases

Popularity67

Solid adoption and visibility

Community36

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~156 days

Recently: every ~284 days

Total

19

Last Release

56d ago

Major Versions

1.5.0 → 2.0.02023-02-10

2.0.0 → 3.0.02024-03-15

3.0.0 → 4.0.02024-12-06

4.0.0 → 5.0.02025-06-13

5.0.0 → 6.0.02026-03-23

PHP version history (3 changes)0.1.0PHP ^7.1

2.0.0PHP ^7.1|^8.0

5.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/863e91ca13b8c4031f202c0eee4f06b3a4352f92cf9cd397b03609b20247ed16?d=identicon)[beyondcode](/maintainers/beyondcode)

---

Top Contributors

[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (31 commits)")[![mechelon](https://avatars.githubusercontent.com/u/26432041?v=4)](https://github.com/mechelon "mechelon (29 commits)")[![textoo](https://avatars.githubusercontent.com/u/205160?v=4)](https://github.com/textoo "textoo (8 commits)")[![mathijso](https://avatars.githubusercontent.com/u/6011297?v=4)](https://github.com/mathijso "mathijso (5 commits)")[![diogogomeswww](https://avatars.githubusercontent.com/u/11543163?v=4)](https://github.com/diogogomeswww "diogogomeswww (5 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![mrunkel](https://avatars.githubusercontent.com/u/3205232?v=4)](https://github.com/mrunkel "mrunkel (2 commits)")[![daniel-werner](https://avatars.githubusercontent.com/u/38726367?v=4)](https://github.com/daniel-werner "daniel-werner (2 commits)")[![ThibaudDauce](https://avatars.githubusercontent.com/u/1770543?v=4)](https://github.com/ThibaudDauce "ThibaudDauce (2 commits)")[![NiclasvanEyk](https://avatars.githubusercontent.com/u/10284694?v=4)](https://github.com/NiclasvanEyk "NiclasvanEyk (2 commits)")[![simondavies](https://avatars.githubusercontent.com/u/689184?v=4)](https://github.com/simondavies "simondavies (1 commits)")[![cworreschk](https://avatars.githubusercontent.com/u/545143?v=4)](https://github.com/cworreschk "cworreschk (1 commits)")[![Yahav](https://avatars.githubusercontent.com/u/113236?v=4)](https://github.com/Yahav "Yahav (1 commits)")[![drbyte](https://avatars.githubusercontent.com/u/404472?v=4)](https://github.com/drbyte "drbyte (1 commits)")[![eiko03](https://avatars.githubusercontent.com/u/23137164?v=4)](https://github.com/eiko03 "eiko03 (1 commits)")[![henryavila](https://avatars.githubusercontent.com/u/8429941?v=4)](https://github.com/henryavila "henryavila (1 commits)")[![iforwms](https://avatars.githubusercontent.com/u/10304616?v=4)](https://github.com/iforwms "iforwms (1 commits)")[![joe-pritchard](https://avatars.githubusercontent.com/u/25373032?v=4)](https://github.com/joe-pritchard "joe-pritchard (1 commits)")[![marzvrover](https://avatars.githubusercontent.com/u/6617862?v=4)](https://github.com/marzvrover "marzvrover (1 commits)")[![orkhanahmadov](https://avatars.githubusercontent.com/u/7041590?v=4)](https://github.com/orkhanahmadov "orkhanahmadov (1 commits)")

---

Tags

beyondcodelaravel-er-diagram-generator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/beyondcode-laravel-er-diagram-generator/health.svg)

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

###  Alternatives

[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[beyondcode/laravel-masked-db-dump

Dump masked information from your database

11341.2k](/packages/beyondcode-laravel-masked-db-dump)[psx/sql

Generate type-safe PHP classes from your database

1773.4k4](/packages/psx-sql)

PHPackages © 2026

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