Search by

janalis / viz

phcorp

Mermaid, Graphviz and PlantUML for PHP: native rendering with a CLI fallback, SVG/PNG/PDF export and conversion between the three

Package info

github.com/janalis/viz

pkg:composer/janalis/viz

Statistics

Installs: 859

Dependents: 3

Suggesters: 0

Stars: 0

Open Issues: 0

v0.2.3 2026-11-07 17:29 UTC

This package is auto-updated.

Last update: 2026-11-07 17:30:24 UTC


README

Viz

Viz

Mermaid, Graphviz and PlantUML for PHP.
Native rendering · SVG, PNG and PDF · conversion between the three

CI Docs Latest release Packagist MIT license

Documentation · Getting started · Rendering · Conversion · Compatibility

Viz renders Mermaid, Graphviz and PlantUML diagrams from PHP 8.5 to SVG, PNG or PDF, and converts between the three languages. Each language is drawn natively, in PHP, with no Node, browser, Graphviz or Java needed; the language's own command-line tool is the fallback for whatever the native renderer leaves.

  • Mermaid: 30+ diagram families, themes and the hand-drawn look, pinned to Mermaid 12.1 (compatibility). Fallback: mmdc.
  • Graphviz: the DOT language and every layout, written clean-room from the published papers and dot's observed output (compatibility). Fallback: dot.
  • PlantUML: every diagram family, ported from PlantUML's MIT distribution and sized as the jar sizes it (compatibility). Fallback: plantuml or its .jar.

Install

composer require janalis/viz

PHP 8.5 with ext-mbstring; ext-gd with FreeType for PNG, ext-zlib for compressed PDF. See Installation for the optional tools.

Quick start

use Janalis\Viz\Viz;
use Janalis\Viz\Render\Format;
use Janalis\Viz\Source\SourceFormat;

$viz = new Viz();
$svg = $viz->render("flowchart LR\n  a --> b", SourceFormat::Mermaid, Format::Svg)->bytes;
$viz->export('digraph { a -> b }', SourceFormat::Dot, 'graph.pdf');   // format from the extension
$dot = $viz->convert($mermaidFlowchart, SourceFormat::Mermaid, SourceFormat::Dot);

More in the guide: rendering and export, native or command line, conversion and the shared models and upgrading from 0.1.

Contributing

Bug reports with the diagram that misbehaves are welcome, as are fixes. Please note the clean-room rule: the native Graphviz is written from published papers and dot's observed output only, never from Graphviz's source. See the development guide.

make install
make verify      # validate, format, lint, analyze, 100% line coverage, audit

Changes go under ## Unreleased in CHANGELOG.md; the Release workflow cuts a version from it (releasing).

License

MIT. The bundled IBM Plex Mono fonts are under the SIL Open Font License (resources/fonts/OFL.txt). The ported parts of Mermaid, PlantUML (its MIT distribution), its Open Iconic icons, HSLuv, khroma, roughjs, d3-shape and d3-format keep their notices in resources/licenses/, as do the Twemoji pictures PlantUML bundles, under CC-BY 4.0.