Download the PHP package byrcsc/laravel-cartographer without Composer

On this page you can find all versions of the php package byrcsc/laravel-cartographer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-cartographer

Laravel Cartographer

Latest Version on Packagist GitHub Tests Action Status GitHub PHPStan Action Status Total Downloads

Generate a Mermaid entity relationship diagram of your Laravel application from its Eloquent models and database schema. Every app eventually needs one: onboarding a developer, planning a migration, working out what still points at a table. Drawn by hand, it is wrong within a month.

The package provides the diagram generator. Your application keeps ownership of its models, its schema, and where the output file lives. Cartographer never reads your data.

Laravel Tested PHP versions
12.x 8.3, 8.4
13.x 8.3, 8.4

Tested on MySQL, PostgreSQL, and SQLite.

One artisan command writes a Markdown file that GitHub and GitLab render on sight. Commit it, and each schema change shows up as a diff in the pull request that caused it.

Installation

Install as a dev dependency:

Publish the config file if you want to change the defaults:

What the diagram is built from

Cartographer never reads your data. It builds every diagram from two sources:

Because the schema is read from the database, it stays correct on apps with squashed migrations, raw SQL migrations, and long migration histories.

Quick start

Generate the full ERD to docs/erd.md:

Everything is included by default. Use the options to limit it:

Option Default Purpose
--models=Order,Invoice all models Seed models to focus on
--depth=2 unlimited How many relationship hops to follow from the seeds
--group=billing all groups Render only one configured group
--only=Order,Invoice all models Scope this run to these models
--except=Telemetry none Leave these models out of this run
--columns=all\|keys\|none all Column detail per entity. keys shows only PK, FK, and unique columns
--exclude-relations=through,morph none Relation types to leave out
--format=markdown\|mmd\|svg\|png markdown Markdown with a mermaid fence, a raw .mmd file, or a rendered image
--theme=light\|dracula light Visual preset for an svg or png export
--font=mono\|sans\|default the theme's own Font stack for an svg or png export
--output=docs/erd.md from config Where the file is written. An svg or png run replaces the extension with the format
--stdout off Print to stdout instead of writing a file
--connection= default connection Which database connection to introspect

What is included

Splitting a big app into groups

One diagram of a hundred tables is a wall, and past a certain size no hosted renderer will draw it at all. Name the subsets your team actually talks about, and each one gets its own committed diagram:

A bare php artisan cartographer:erd now writes the full diagram plus one file per group, derived from the main output path: docs/erd.md gives docs/erd/billing.md and docs/erd/catalog.md. Give a group an output key to place its file elsewhere. --group=billing regenerates one on its own, and cartographer:check covers every group alongside the full diagram.

A relation that leaves a group keeps its edge, and the model on the far side is drawn as an empty box. You can see that an invoice belongs to a user without the billing diagram growing a copy of the user table:

For a one-off diagram that is not worth committing, --only and --except scope a single run without touching the group files. --only scopes the diagram the way a group does, stubs and all. --except removes those models entirely, on top of whatever exclude_models already drops.

See Diagrams per subsystem and Scoping a diagram.

Rendering to SVG or PNG

Text output is the default because it reviews well and every host draws it. When you need a picture instead, --format=svg and --format=png render one through a locally installed mermaid-cli:

mermaid-cli is never a dependency of this package. Cartographer looks for it at export.mermaid_cli, then in your project's node_modules/.bin/mmdc, then on your PATH, and tells you how to install it if none of those has one.

An export writes the rendered docs/erd.svg and the Mermaid source it came from at docs/erd.svg.mmd. The source is written beside the image because that is what cartographer:check compares: mermaid-cli output is not byte-stable between its own versions, so checking the image itself would report drift every time someone upgraded it. Checking never runs mermaid-cli, so CI can verify an exported diagram without installing node.

Two presets are built in, light and dracula, and --font swaps a preset's font stack for mono, sans, or Mermaid's own default. Define your own under themes and select it by name exactly like a built-in. Themes never enter the Mermaid source: they are passed to the renderer at export time, so committed Markdown stays theme-neutral and GitHub keeps theming it to whatever the reader has chosen.

See Exporting images and Themes and fonts.

Keeping it honest in CI

A committed diagram is only useful while it is true. cartographer:check regenerates everything your config declares, compares it against the files on disk, and exits 1 listing each stale or missing file with a short diff and the command that fixes it:

It writes nothing, so it is safe on a read-only checkout. The diagram is built from your database structure, so the check needs a migrated database in the same way your test suite does:

--group=billing checks one group and --connection= picks the connection. Use --group to split the check across CI jobs, never as the only check: a bare cartographer:check is what proves every committed file is current.

See Continuous integration.

Configuration

The published config/cartographer.php documents every key inline.

Key Default Purpose
paths app_path('Models') Directories scanned for models. Globs are supported
exclude_models [] Model classes to leave out of every diagram
connection null Connection to introspect. Null uses your default
output docs/erd.md Output location, relative to the project root
format markdown Renderer format: markdown, mmd, svg, or png
columns.mode all Column detail per entity: all, keys, or none
columns.exclude [] Columns to hide, keyed by model class
export.mermaid_cli null Path to a mermaid-cli binary. Null searches node_modules/.bin/mmdc, then PATH
export.theme light Preset for an image export
export.font null Font stack for an image export. Null uses the theme's own
themes [] Your own export presets, selectable by name
groups [] Named subsets that each get their own diagram
limits.max_text_size 50000 Warn past this many characters of source. Null switches the check off
limits.max_edges 500 Warn past this many edges. Null switches the check off
relations.exclude [] Relation types to leave out, such as through or morph
relations.strict_types_only false Only inspect methods with a declared Relation return type

Full defaults and validation rules are in the configuration reference.

Important behavior

Documentation

Development

The local checks mirror CI:

PHPStan runs at max with no baseline. Tests use SQLite locally and run against MySQL and PostgreSQL in CI. tests/SurfaceTest.php pins the public class list, and the snapshots under tests/.pest/ pin the rendered diagram output. A failure in either is asking whether you meant to change what users see. See CONTRIBUTING.md.

workbench/ is a bootable demo application with a schema that exercises every relation type the detector supports. composer build sets it up and composer serve runs it.

Out of scope

Things this package will not do, so you can decide quickly whether it fits:

Versioning

The package follows semantic versioning.

One deliberate exception: the exact layout of the generated diagram is not covered. Cardinality notation, edge labels, and column ordering may be refined in a minor release, which will show up as a diff in your committed ERD the next time you regenerate it. Determinism is guaranteed, so a given schema always produces the same file on a given version, but the rendering itself is free to improve. Anything that moves lines gets a changelog entry.

Bug fixes go into the newest version only. To get a fix, upgrade to it.

Questions and issues

This package is maintained by one person, so replies can take a while. Everything gets read.

License

MIT. See CHANGELOG.md.


All versions of laravel-cartographer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/console Version ^12.0 || ^13.0
illuminate/database Version ^12.0 || ^13.0
illuminate/filesystem Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
symfony/process Version ^7.2 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package byrcsc/laravel-cartographer contains the following files

Loading the files please wait ...