A PlantUML generator for graph-uml

1.0.0-rc.2 2020-09-10 11:28 UTC

This package is auto-updated.

Last update: 2021-09-10 14:31:02 UTC


Latest Stable Version Minimum PHP Version License


Generate UML diagrams in PlantUML format.

Note: This project is in beta stage! Feel free to report any issues you encounter.


The main features provided by this library are:

  • build UML statements of a class diagram
  • build image in one of the supported formats with local plantuml.jar executable


The recommended way to install this library is through composer. If you don't know yet what is composer, have a look on introduction.

composer require bartlett/graph-plantuml-generator

Additionally, you'll have to install PlantUML jar and Java Runtime (java executable). Users of Debian/Ubuntu-based distributions may simply invoke:

$ sudo apt update
$ sudo apt-get install openjdk-11-jre-headless

while remaining users should install from PlantUML Download page.

You can also use the PlantUML demo server at

Quick Start

Once installed, you can use the following code to draw an UML class diagram for your existing classes:


use Bartlett\GraphUml\ClassDiagramBuilder;
use Bartlett\GraphPlantUml\PlantUmlGenerator;

use Graphp\Graph\Graph;

$generator = new PlantUmlGenerator();
$graph = new Graph();
$builder = new ClassDiagramBuilder(
        'label_format' => 'default',


// personalize render
$graph->setAttribute('graph.bgcolor', 'transparent');
$graph->setAttribute('cluster.Bartlett\\GraphPlantUml.graph.bgcolor', 'lightsteelblue');
$graph->setAttribute('cluster.Bartlett\\GraphUml\\Generator.graph.bgcolor', 'SteelBlue');

// show UML diagram statements
echo $generator->createScript($graph);
// default format is PNG
echo $generator->createImageFile($graph) . ' file generated' . PHP_EOL;

That should give such output:

Single Class UML

NOTE You can use $generator->getPrefix() (that will return blank, because its not used here), for each setAttribute if you want to keep the same syntax for whatever generator.


Full documentation is written in MarkDown format, and HTML export is possible with See output results at or raw *.md files in docs folder.

Table of Contents



  • Laurent Laville (Lead Developer)