PHPackages                             eloqviz/laravel-eloquent-viz - 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. eloqviz/laravel-eloquent-viz

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

eloqviz/laravel-eloquent-viz
============================

Eloquent model relationship graph: JSON API, artisan command, and Cytoscape.js UI for Laravel applications.

0.1.2(1mo ago)01↓100%MITPHPPHP ^8.2CI passing

Since May 9Pushed 1mo agoCompare

[ Source](https://github.com/iamariezflores/eloqviz)[ Packagist](https://packagist.org/packages/eloqviz/laravel-eloquent-viz)[ RSS](/packages/eloqviz-laravel-eloquent-viz/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (4)Versions (1)Used By (0)

EloqViz (`eloqviz/laravel-eloquent-viz`)
========================================

[](#eloqviz-eloqvizlaravel-eloquent-viz)

[![Packagist Version](https://camo.githubusercontent.com/72cd38676432ea7a2c9145b0e3725b3fe42a6b3821ab8ae9ee63ded89ae85a14/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c6f7176697a2f6c61726176656c2d656c6f7175656e742d76697a)](https://packagist.org/packages/eloqviz/laravel-eloquent-viz)[![PHP](https://camo.githubusercontent.com/406f278b6e2f8a45e7fbfdceb80e2cd1e7e737c5ce9de820ae236c22b939ccbe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f656c6f7176697a2f6c61726176656c2d656c6f7175656e742d76697a)](https://packagist.org/packages/eloqviz/laravel-eloquent-viz)[![License](https://camo.githubusercontent.com/3196cb2cf4ccfd328b2dc506213d689305f94d56acf1c75fbac411fecf017cf8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f656c6f7176697a2f6c61726176656c2d656c6f7175656e742d76697a)](https://packagist.org/packages/eloqviz/laravel-eloquent-viz)

**EloqViz** is a small Laravel package for developers who need to **see Eloquent relationships at a glance**—especially in large codebases with many models and edges. There is no dashboard or extra ceremony: scan `Model` classes, render a directed graph (or JSON), and focus the view when the full picture is too dense.

This repository **is** the package source (PHP, Blade, bundled Cytoscape UI). Consume it via Composer inside any Laravel application; local work here uses [Orchestra Testbench](https://github.com/orchestra/testbench) for tests instead of maintaining a demo Laravel app.

Available on Packagist: **[eloqviz/laravel-eloquent-viz](https://packagist.org/packages/eloqviz/laravel-eloquent-viz)**

Expectations (what this is and isn’t)
-------------------------------------

[](#expectations-what-this-is-and-isnt)

**EloqViz is an inspection and orientation tool**—it reflects what Eloquent **declares in model code** (relation methods you can probe), not a substitute for migrations, DB dumps, or governance suites.

**Use it when****Don’t expect it to**Onboarding or auditing a **large or unfamiliar** codebase (many models, modules, packages).Replace **formal schema docs** or stay in sync if relations are built only in services/repos with no model methods.**Refactoring** or module splits: “what touches what” before you move tables or rename pivots.Prove **runtime** behaviour for every edge case (dynamic relations, heavy `newQuery()` tricks, cross-DB).Keeping a **code-accurate sketch** of relationships when written as standard Eloquent relations.Act as an **admin CRUD** framework, ORM designer, or Laravel Nova–style resource UI.**Smaller apps** with a handful of models often don’t need a graph; value **scales with size and unfamiliarity**. Teams sometimes pipe the **JSON** into custom checks or docs—that’s optional and up to you.

What you get
------------

[](#what-you-get)

- **Routes (no route file)** — The service provider **registers routes in code**, so installing the package is enough (`GET /{prefix}` for the UI, `GET /{prefix}/graph` for JSON). You do **not** need to paste routes into `routes/web.php`; adjust **`route_prefix`** and **`middleware`** in config when publishing.
- **Web UI** — Interactive graph (Cytoscape.js): stable **FQCN node ids**, configurable **labels**, search across label / FQCN / file path, **scan notes** (warnings + skipped relation probes), selection panel shows **FQCN + file** for each model.
- **JSON (`graphVersion` 2)** — Full graph payload with diagnostics (see below).
- **Artisan** — `php artisan eloquent:graph` prints the same JSON. Use **`--path=`** repeatedly (or once) to override config directories.

Relationships are discovered by inspecting public relation methods on each non-abstract Eloquent model. Each candidate method runs once inside `Model::withoutEvents()` and `Connection::pretend()` on that model’s connection so typical relations never hit the database.

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

[](#requirements)

- PHP **8.2+**
- Laravel **11.44+** or **12.x**

Install in a Laravel application
--------------------------------

[](#install-in-a-laravel-application)

```
composer require eloqviz/laravel-eloquent-viz
php artisan vendor:publish --tag=eloquent-viz
```

That single tag publishes **`config/eloquent-viz.php`** and the **bundled JS** under `public/vendor/eloquent-viz/`. Granular tags **`eloquent-viz-assets`** / **`eloquent-viz-config`** still exist.

Then visit **`/{your-prefix}`** (default **`/eloquent-viz`**). **`/{prefix}/graph`** returns JSON only.

When **`APP_ENV=production`**, EloqViz **does not register** HTTP routes or the `eloquent:graph` Artisan command—the graph is unreachable and the inspector cannot be run via Artisan. Outside production you can still add auth or custom middleware via **`middleware`** as needed.

Configuration (`config/eloquent-viz.php`)
-----------------------------------------

[](#configuration-configeloquent-vizphp)

KeyPurpose`route_prefix`URL prefix for UI + JSON.`middleware`Route middleware stack (default `web`).`models_paths`List of directories to scan recursively for `*.php` models.`models_directory`**Legacy only** — if set, overrides `models_paths` until removed.`node_display``short` (default), `fqcn`, or `namespace_suffix` (`Post · App\Models`). With `short`, **duplicate basenames** in the same graph automatically get a disambiguating suffix.`include_file_paths`When true, each node includes a `file` path (relative to the app root when under `base_path()`, otherwise absolute).`scan_diagnostics`When true, populate `warnings` and `skippedRelations` (e.g. declared relation return type but runtime did not return a `Relation`).Configuration is **PHP only** (no `.env` keys from this package).

### `models_paths` example

[](#models_paths-example)

```
'models_paths' => [
    app_path('Models'),
    base_path('modules/Billing/src/Models'),
],
```

JSON API (`GET {prefix}/graph`, `eloquent:graph`)
-------------------------------------------------

[](#json-api-get-prefixgraph-eloquentgraph)

**`graphVersion`** is `2`. Breaking change from older builds: **`nodes` are objects**, **`edges.from` / `edges.to`** are **FQCNs** (same as node `id`), not short class names.

### Payload shape

[](#payload-shape)

- **`graphVersion`**: `2`
- **`nodes`**: `[{ "id": "", "label": "", "fqcn": "", "file": "" }]`
- **`edges`**: `[{ "from": "", "to": "", "type": "belongsTo", "smart": { ... }, "multiplicity"?: n }]`
- **`warnings`**: `[{ "code": "...", "message": "...", ... }]`, e.g. `graph.external_model` when a related class is outside `models_paths`, or `graph.ambiguous_basename` / `graph.ambiguous_default_user` when `?model=` or default `User` focus is ambiguous.
- **`skippedRelations`**: `[{ "model": "", "method": "...", "reason": "..." }]` for methods that advertise a relation return type but do not yield a `Relation` at runtime.
- **`availableModels`** (HTTP only): `[{ "id": "", "label": "" }]` for the root-model dropdown (full scan, no component filter).
- **`selectedModel`**: FQCN of the focused model, or `null` (all models / no default when ambiguous).

**`?model=`** accepts either a **full class name** or a **basename** when it is unique among scanned models.

Develop this repo
-----------------

[](#develop-this-repo)

```
composer install
npm install
npm run build
composer test
composer format   # Laravel Pint, after PHP edits
```

Honest limits
-------------

[](#honest-limits)

The graph is **best-effort static + one guarded call per candidate method** under `pretend()` / `withoutEvents()`. That is the right trade-off for most apps, not a guarantee for every pattern.

- **Cross-connection / exotic relations** may still run outside the scanned model’s `pretend()` scope; **warnings** and **skipped relations** record what we could detect.
- **Abstract** base `Model` classes are not listed as nodes.
- Relations defined **only** outside model methods (raw query builders, arbitrary PHP) will not appear as edges.

If you need a line in your internal docs: **“EloqViz shows the Eloquent surface of the codebase you configured to scan—not the full business or database story.”**

License
-------

[](#license)

MIT.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance94

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

31d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44970520?v=4)[Aquilino Flores](/maintainers/iamariezflores)[@iamariezflores](https://github.com/iamariezflores)

---

Top Contributors

[![iamariezflores](https://avatars.githubusercontent.com/u/44970520?v=4)](https://github.com/iamariezflores "iamariezflores (10 commits)")

---

Tags

laravelormeloquentgraphvisualizationcytoscape

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/eloqviz-laravel-eloquent-viz/health.svg)

```
[![Health](https://phpackages.com/badges/eloqviz-laravel-eloquent-viz/health.svg)](https://phpackages.com/packages/eloqviz-laravel-eloquent-viz)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11122.5M32](/packages/anourvalar-eloquent-serialize)[mostafaznv/laracache

LaraCache is a customizable cache trait to cache queries on model's events

27249.4k2](/packages/mostafaznv-laracache)[wayofdev/laravel-cycle-orm-adapter

🔥 A Laravel adapter for CycleORM, providing seamless integration of the Cycle DataMapper ORM for advanced database handling and object mapping in PHP applications.

3729.5k3](/packages/wayofdev-laravel-cycle-orm-adapter)[waad/laravel-model-metadata

A robust Laravel package for handling metadata with JSON casting, custom relation names, and advanced querying capabilities.

854.1k](/packages/waad-laravel-model-metadata)[mozex/laravel-scout-bulk-actions

Import, flush, and queue-import all your Laravel Scout searchable models at once. Auto-discovers models, runs in bulk, tracks progress.

1437.7k](/packages/mozex-laravel-scout-bulk-actions)[mostafaznv/nova-laracache

LaraCache Tool for Laravel Nova

113.9k](/packages/mostafaznv-nova-laracache)

PHPackages © 2026

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