Application 2020-06-26

Tool for Automatically Generating UML with PHP - phUML

Generate PHP class diagrams automatically using phUML to visualize design architecture and understand complex structures.

Read in: ja
Tool for Automatically Generating UML with PHP - phUML

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

You can also install it with composer.

composer require phuml/phuml

Once installed,

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

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.

Tags: PHP
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ Support

If you enjoy this blog, consider supporting it. Every bit helps keep it running!


Related Articles