PHP code example of jawira / plantuml-to-image

1. Go to this page and download the library: Download jawira/plantuml-to-image library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jawira / plantuml-to-image example snippets


use Jawira\PlantUmlToImage\Format;
use Jawira\PlantUmlToImage\PlantUml;

// Load diagram
$puml = file_get_contents('./diagram.puml');

// Convert to png
$plantUml = new PlantUml();
$png = $plantUml->convertTo($puml, Format::PNG);

// Save diagram
file_put_contents('./diagram.png', $png);

$plantUml->setJar('/path/to/plantuml.jar');

if ($plantUml->isPlantUmlAvailable()) {
  echo 'PlantUml is available.', PHP_EOL;
} else {
  echo 'Sorry, cannot convert diagram.', PHP_EOL;
}