jawira/plantuml-encoding
PHP library providing PlantUML text encoding helpers. Use encodep() to convert an @startuml diagram (UTF-8) into the compressed URL-safe string used by plantuml.com. Includes encode6bit(), append3bytes(), and encode64().
Install the package via Composer:
composer require jawira/plantuml-encoding
Start encoding UML text in seconds — the core use case is generating embeddable PlantUML URLs for diagrams. For example, in a Blade template:
@php
$uml = "@startuml
Alice -> Bob: Hello
Bob --> Alice: Hi there!
@enduml";
$encoded = \Jawira\PlantUmlEncoding\PlantUml::encode($uml);
@endphp
<a href="https://www.plantuml.com/plantuml/svg/{{ $encoded }}">View Diagram</a>
First check the README on GitHub (repository link in docs) for the encode() method signature and optional compression/encoding flags.
route() or url() helpers to create dynamic diagram URLs for docs, dashboards, or emails:
$url = "https://www.plantuml.com/plantuml/svg/" . PlantUml::encode($umlSource);
$cacheKey = 'uml:' . md5($umlSource);
$encoded = Cache::remember($cacheKey, 600, fn() => PlantUml::encode($umlSource));
@component('components.plantuml', ['uml' => $code])
<img src="{{ $encodedUrl }}" alt="UML Diagram">
@endcomponent
$this->assertEquals($expectedEncodedString, PlantUml::encode($uml));
/png/, /svg/) or break diagrams into smaller components.gzdeflate errors.+// with -/_, so don’t use base64_encode() or urlencode() manually—the encode() method handles all normalization and escaping.deflate. If troubleshooting compatibility with older servers, check for encodeRaw() (no compression) in the docs—but avoid it unless necessary.Compressor, Base64Encoder)—you can subclass them for custom behavior (e.g., alternative compression algorithms), though this is rarely needed.How can I help you explore Laravel packages today?