PHP Classes

File: docs/index.md

Recommend this page to a friend!
  Classes of jawira   PlantUML client   docs/index.md   Download  
File: docs/index.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: PlantUML client
Convert a UML diagram to an image using PlantUML
Author: By
Last change:
Date: 2 years ago
Size: 882 bytes
 

Contents

Class file image Download

Introduction

How to install

composer require jawira/plantuml-client

Four methods are exposed:

  • \Jawira\PlantUmlClient\Client::generateImage
  • \Jawira\PlantUmlClient\Client::generateUrl
  • \Jawira\PlantUmlClient\Client::setServer
  • \Jawira\PlantUmlClient\Client::getServer

Generate image from diagram

use Jawira\PlantUmlClient\Client;
use Jawira\PlantUmlClient\Format;

$puml = <<<PLANTUML
@startuml
Bob -> Alice : hello
@enduml
PLANTUML;

$client = new Client();
$svg = $client->generateImage($puml, Format::SVG);

Load diagram form disk

use Jawira\PlantUmlClient\Client;
use Jawira\PlantUmlClient\Format;

$puml = file_get_contents('path/to/my-diagram.puml'); // load png file

$client = new Client();
$png = $client->generateImage($puml, Format::PNG);

file_put_contents('path/to/my-diagram.png', $png); // save png to disk