DEV Community

Cover image for Tool for Automatically Generating UML with PHP - phUML
Kenta Takeuchi
Kenta Takeuchi

Posted on • Originally published at bmf-tech.com

Tool for Automatically Generating UML with PHP - phUML

This article was originally published on bmf-tech.com.

Overview

I wanted a tool that could automatically generate UML when I needed to grasp the overview of class design. While PhpStorm apparently has a nice built-in feature to generate diagrams, I've committed to VSCode, so I had to find a suitable tool.

phUML

After some googling, I found various tools, but I was looking for something easy to use.

github.com - MontealegreLuisphuml
Documentation

The original? github.com - jakobwsthoff/phuml seems to have ended maintenance, but I found a forked version like the one above.

It doesn't have many stars, so it seems not many people use it... but it looked usable, so I tried it out.

It supports PHP version ^7.1.

I used it in a 7.3 environment.

Installation

$ wget https://montealegreluis.com/phuml/phuml.phar
$ wget https://montealegreluis.com/phuml/phuml.phar.pubkey
$ chmod +x phuml.phar
$ mv phuml.phar /usr/local/bin/phuml
$ mv phuml.phar.pubkey /usr/local/bin/phuml.pubkey
Enter fullscreen mode Exit fullscreen mode

You can also install it with composer.

composer require phuml/phuml
Enter fullscreen mode Exit fullscreen mode

Once installed,

vendor/bin/phuml phuml:diagram -r -a -i -o -p dot path/to/classes example.png
Enter fullscreen mode Exit fullscreen mode

Using a bunch of suspicious-looking options like this will generate a class diagram.

You can check the options in the documentation.
phUML - Generate a class diagram

It seems you can specify options to exclude certain accessors from the output.

Impressions

It seems useful for getting an overview when you want to understand a larger design. It would be nice if there was a VSCode plugin, but there isn't one at the moment.

Top comments (0)