›
›
›
  1. docs
  2. ›
  3. byrcsc/laravel-cartographer
1.x
Browse documentationOpenClose

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • How a diagram is built
  • Model discovery
  • Relationship detection
  • Schema introspection
  • Scoping a diagram

Operations

  • Diagrams per subsystem
  • Exporting images
  • Themes and fonts
  • Renderer limits
  • Keeping the diagram current
  • Continuous integration

Reference

  • Configuration
  • Console commands
  • Diagram syntax
  • PHP API
  • Testing
  • Troubleshooting

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • How a diagram is built
  • Model discovery
  • Relationship detection
  • Schema introspection
  • Scoping a diagram

Operations

  • Diagrams per subsystem
  • Exporting images
  • Themes and fonts
  • Renderer limits
  • Keeping the diagram current
  • Continuous integration

Reference

  • Configuration
  • Console commands
  • Diagram syntax
  • PHP API
  • Testing
  • Troubleshooting

byrcsc/laravel-cartographer · 1.x

Renderer limits.

Detect diagrams that exceed hosted Mermaid character or edge limits.

Hosted Mermaid renderers cap how much they will draw. GitHub, GitLab, and the Mermaid live editor all stop at 50,000 characters of diagram source (maxTextSize) and 500 relationship edges (maxEdges). Past either one they show "Maximum text size in diagram exceeded" where the diagram should be.

Cartographer warns you when a generated diagram crosses a limit, on the run that caused it rather than in a pull request.

   WARN  The diagram is 63,412 characters, over the 50,000 character limit
         hosted Mermaid renderers enforce (maxTextSize). GitHub and GitLab
         report "Maximum text size in diagram exceeded" instead of drawing it.
         The file itself is valid Mermaid and was written unchanged. Shrink it
         with --columns=keys or --columns=none, split it into groups under
         [cartographer.groups], render it yourself with --format=svg, or raise
         [cartographer.limits.max_text_size] if your renderer is configured for
         more.

The diagram is never trimmed to fit

This is the important half. The generated file is valid Mermaid at any size, and it is written unchanged whether or not it crossed a limit. A renderer you control can be configured to draw it, and the export formats do exactly that.

The warning never changes the exit code either. A run that trips it still returns 0, and cartographer:check still passes on a file that is correct but too big for GitHub. The limits describe a rendering environment, not a defect in your schema, so failing on them would be failing on somebody else's configuration.

What is measured

LimitMeasured onDefault
max_text_sizeCharacters of raw Mermaid source, without the wrapper50000
max_edgesRelationship edges in the diagram500

Two details follow from that. Characters are counted with multibyte awareness, matching how Mermaid measures maxTextSize, so a schema with non-ASCII table or column names is measured the way the renderer will measure it. And the Markdown wrapper is excluded, because the generation comment and the fence are not part of what the renderer parses.

Each declared diagram is measured on its own. Splitting into groups is therefore a real fix rather than a way of moving the total around: a group that fits is drawn, whatever the full diagram measures.

The ways out, cheapest first

1. Emit fewer columns

php artisan cartographer:erd --columns=keys

keys keeps only PK, FK, and UK columns and usually halves the source on a wide schema. --columns=none drops the column blocks entirely and halves it again, leaving entity names and edges, which is the right shape for an orientation diagram anyway.

This does nothing for maxEdges. Columns are not edges.

2. Split into groups

'groups' => [
    'billing' => [App\Models\Invoice::class, App\Models\Payment::class],
    'catalog' => [App\Models\Product::class, App\Models\Category::class],
],

The structural answer, and the only one that helps both limits at once. Each group is a committed diagram of its own, measured on its own, and a relation leaving a group keeps its edge with the far entity drawn as an empty box. See diagrams per subsystem.

3. Render it yourself

php artisan cartographer:erd --format=svg

Cartographer supplies the renderer configuration for an export and raises both limits far past anything a schema produces. An export succeeds on diagrams GitHub refuses to draw, and no size warning is printed for one. See exporting images.

4. Scope the diagram

php artisan cartographer:erd --models=Invoice,Payment --depth=1

Seeds and depth render one subsystem instead of the whole application. Good for a one-off; groups are better for anything committed, because a group regenerates with every run and a remembered flag does not. See scoping a diagram.

5. Drop the relation types that fan out

php artisan cartographer:erd --exclude-relations=through,morph

Aimed squarely at maxEdges. through relations are shortcuts across an intermediate model, so each one adds an edge the diagram already implies through two others. Polymorphic relations fan out to every model that participates.

Raising or switching off a limit

If you render with your own Mermaid configuration and have raised its limits, set the matching key to your number, or to null to switch that check off:

'limits' => [
    'max_text_size' => 200000,
    'max_edges' => null,
],

Each key is independent, so you can switch off the edge check and keep the text check. A value must be null or a positive integer:

   ERROR  [cartographer.limits.max_edges] must be null or a positive integer.

Switch a limit off only when you know the renderer that will draw the file. Setting both to null because the warning is noisy means the first person to open the diagram on GitHub finds out instead of you.

Under --stdout

--stdout prints the diagram and nothing else, so warnings are suppressed along with the summary line. If you are piping a large diagram and want to know whether it is over a limit, run once without --stdout.

What to read next

  • Diagrams per subsystem for splitting a large application into groups.
  • Exporting images for rendering past the limits yourself.
  • Configuration for the limits keys beside every other key.
PreviousThemes and fontsNextKeeping the diagram current
View source

On this page

  1. The diagram is never trimmed to fit
  2. What is measured
  3. The ways out, cheapest first
  4. 1. Emit fewer columns
  5. 2. Split into groups
  6. 3. Render it yourself
  7. 4. Scope the diagram
  8. 5. Drop the relation types that fan out
  9. Raising or switching off a limit
  10. Under --stdout
  11. What to read next