Automatically generate class diagram from PHP source code

Sep 7, 2020 PHP uml PHUML

Create PHP class diagram with images with #PHUML

It seems that PHPSTORM has a function to create a class diagram, but since PHPSTORM is not included in the home environment, I was looking for a tool that automatically generates a class diagram and found a tool called phuml. The environment is Ubuntu 18.04 LTS.

Install

https://github.com/jakobwesthoff/phuml Download it from and extract it to a suitable location. I deployed it as phuml in ~ / .local. You can now run it.

$ php ~ / .local / phuml / src / app / phuml
phUML Version 0.2 (Jakob Westhoff <[email protected]>)
Usage: phuml [-h | -l] [OPTIONS] <DIRECTORY> <PROCESSOR> [PROCESSOR OPTIONS] ... <OUTFILE>

Commands:
    -h Display this help text
    -l List all available processors

Options: Options:
    -r Scan given directorie recursively

Example:
    phuml -r ./ -graphviz -createAssociations false -neato out.png

    This example will scan the current directory recursively for php files.
    Send them to the "dot" processor which will process them with the option
    "createAssociations" set to false. After that it will be send to the neato
    processor and saved to the file out.png

It’s hard for me to enter it every time, so I put a symbolic link on it.

sudo ln -si ~ / .local / phuml / src / app / phuml / usr / local / bin

After that, move to the directory you want to analyze and have it in the sample

phuml -r ./ -graphviz -createAssociations false -neato out.png

It is OK if you execute and raise it. I tried running it in the src directory of passport, one of the laravel ecosystem.

passport_src.png

I was able to display it properly!