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.

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.

phuml -h
phuml -h

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

./phuml -l

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



  1. hiddenpearls February 21, 2016 at 9:15 am

    phUML is a great tool. Thanks for the detailed guide.

    It was helpful.

  2. KUSHAL BHATTAD April 27, 2016 at 1:12 pm

    how can i use it on windows.?

    1. Nurlan July 18, 2017 at 3:34 pm

      Could you install and run it on Windows? If yes, share the experience please.

      1. Arya Rao Cheeti March 11, 2021 at 12:17 pm

        So can you run it on windows?

  3. Ken Guest July 12, 2016 at 8:51 pm

    Please tell me you’re not really running that as root! :-)

  4. Raj October 24, 2016 at 9:16 am


    where does the images save. I have executed the commands. can you please clear me.

    1. Alexandre Comeau March 18, 2017 at 2:01 am

      It saves in the directory you are running the command from.

      1. alex November 25, 2020 at 6:45 pm

        Hi, I cant find the output image, Would it be in the phuml/src/app folder just right next to the executable ? Please help

  5. Elroy Jetson June 27, 2017 at 5:32 pm

    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?


Leave A Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.