Today we are going to talk about UML Generator called phUML which is written in PHP. phUML is one of the best tools I have encountered to generate a class diagram from the existing PHP code. This is a common need when it comes to agile methodology. At some point we all have to write code 1st then do the documentation such as draw class diagrams for future references which is crucial for project success. There are tons of tools but most of them are paid or else not working properly but this tool is golden. Okay now if you ask me what’s phUML is, the answer is right below.
phUML is fully automatic UML class diagramm generator written PHP. It is capable of parsing any PHP5 object oriented source code and create an appropriate image representation of the oo structure based on the UML specification.
The image below here is the generated class diagram which phUML created when run on a particular codebase.
Okay let’s get down to business.
1. Download & Configure
You can download phUML from here or here.
phUML depends on graphviz library. So you have to install graphviz on your Ubuntu instance. To get it done use below commands.
sudo apt-get update sudo apt-get install graphviz
If you come across any errors or if you need to get more info here and here.
2. Let’s Generate
Now naviagate to the folder where the phUML is downloaded and extracted.
cd /home/dasunhegoda/Desktop/phuml/
Okay now navigate to where phUML executable is
cd /src/app/
Execute below command.
./phuml -r /var/www/php_app_folder -graphviz -createAssociations false -neato output_image.png
-r is given to scan given directories recursively. Plus if you need associations set the it to true.
Tip & Tricks
You can get the help text using below command.
./phuml -h
See the output below.
Also you can list the processors are available using below command.
./phuml -l
See the output below.
As they say, you should play around with phUML command-line tool to get a better understanding of what the processors do and how they work. See like I told you generating class diagram from an existing codebase is not that hard. If you need more information on PHP UML generators try this link as well.
If you have any questions let me know in the comments below. Your feedback is highly appreciated(happy-face).
phUML is a great tool. Thanks for the detailed guide.
It was helpful.
Thanks
how can i use it on windows.?
Could you install and run it on Windows? If yes, share the experience please.
So can you run it on windows?
Please tell me you’re not really running that as root! :-)
hi..
where does the images save. I have executed the commands. can you please clear me.
It saves in the directory you are running the command from.
Hi, I cant find the output image, Would it be in the phuml/src/app folder just right next to the executable ? Please help
sfdgsdgfsdfg
This is a great tool. It looks like it’s not maintained anymore. It really needs to support static method and namespaces, as well as attribute types.. Is there anything else like this out there?