AtelierDiagram
Turn structured data into clean, readable diagrams.
Diagrams that run entirely in PHP: build a typed model or parse supported Mermaid, then render SVG and emit canonical Mermaid again. No browser, JavaScript runtime, or external CLI.
Features
- Fifteen families
State, flowchart, sequence, class, ER, Git graph, timeline, journey, mindmap, requirement, Kanban, block, architecture, C4, Venn. - A builder per family
Each one speaks its own domain: states and transitions, participants and messages, commits and branches. It returns a typed model, not markup. - Mermaid in, with a line number
Fourteen families parse a documented subset. Anything outside it throws aParseExceptioncarrying the offending line, rather than rendering something else. - Mermaid back out
toMermaid()re-emits canonical source from the model andtoMarkdown()fences it for a README. Round-trip tests hold both directions. - Deterministic SVG
No browser, no JavaScript runtime, no external binary.toSvgDocument()hands back an Atelier SVG document when the diagram has to compose into a larger drawing. - Five themes, every field yours
Default, dark, blueprint, mono and neutral. Colour, typography, spacing, strokes and background patterns are fields you can override.
Build a state machine
use Atelier\Diagram\Diagram;
$model = Diagram::state()
->title('Order lifecycle')
->initial('Draft')
->transition('Draft', 'Review', 'submit')
->transition('Review', 'Approved', 'approve')
->final('Approved')
->build();
It also parses a supported Mermaid subset and can serialize the model back to canonical Mermaid.
Parse Mermaid
use Atelier\Diagram\Diagram;
$diagram = Diagram::fromMermaid(<<<'MERMAID'
sequenceDiagram
User->>Api: Checkout
Api-->>User: Receipt
MERMAID);
Configuration
Pass a theme when rendering. Built-in themes include Theme::default(), Theme::dark(), Theme::blueprint(), Theme::mono(), and Theme::neutral(). Themes control colour, typography, spacing, strokes, and optional background patterns before the scene is rendered.
use Atelier\Diagram\Theme\Theme;
$svg = Diagram::of($model)->toSvg(Theme::dark());
Export
The same model can be rendered as SVG or serialized back to canonical Mermaid.
$diagram = Diagram::of($model);
$svg = $diagram->toSvg();
$mermaid = $diagram->toMermaid();
$diagram->saveSvg('order.svg');
Documentation
Start
- Getting started: build, render, and save a first diagram.
- Every diagram type: compare all fifteen families and open their complete references.
Diagram families
- Flows and behavior: Flowchart, State, Sequence, and Journey.
- Systems and data: Class, ER, Architecture, and C4.
- Planning and structure: Git graph, Timeline, Mindmap, Requirement, Kanban, and Block.
- Sets: Venn.
Input and output
- Mermaid: inspect the supported syntax and round-trip behavior.
- Renderers: render SVG or serialize the model to Mermaid.
- Theming: start from a preset or define a complete visual theme.