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.

phuml generated class diagram

phUML generated class diagram

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.

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.

Okay now navigate to where phUML executable is

Execute below command.

-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.

See the output below.

phuml -h

phuml -h

Also you can list the processors are available using below command.

See the output below.

phuml -l

phuml -l

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).

Be Sociable, Share!