Atelier

AtelierDiagram

Turn structured data into clean, readable diagrams.

composer require atelier/diagram v0.7.0

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.

Order lifecycleDraftIn reviewApprovedRejectedsubmitapproverejectrevise
A state machine rendered by Atelier Diagram from its typed PHP model.

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 a ParseException carrying the offending line, rather than rendering something else.
  • Mermaid back out
    toMermaid() re-emits canonical source from the model and toMarkdown() 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();

Diagram::of($model)->saveSvg('order.svg');

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);

$svg = $diagram->toSvg();
$canonical = $diagram->toMermaid();

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;

Diagram::of($diagram)->toSvg(Theme::dark());

Install

composer require atelier/diagram