PHP UML Generator

153,971

Solution 1

There's also the PHP UML tool available from pear.

PHP_UML:

  • Can generate UML/XMI files in version 1.4, or in version 2.1 (logical, component, and deployment views)
  • Can generate an API documentation in HTML format
  • Can generate PHP code (code skeleton) from a given XMI file
  • Can convert UML/XMI content from version 1.4 to version 2.1

Install it on the command line via:

$ pear install pear/php_uml

(This used to be $ pear install pear/php_uml-alpha but the package has since gone stable.)

Generate your xmi:

$ phpuml -o project.xmi

Solution 2

I strongly recommend BOUML which:

  • is extremely fast (fastest UML tool ever created, check out benchmarks),
  • has rock solid PHP import and export support (also supports C++, Java, Python)
  • is multiplatform (Linux, Windows, other OSes),
  • is full featured, impressively intensively developed (look at development history, it's hard to believe that such fast progress is possible).
  • supports plugins, has modular architecture (this allows user contributions, looks like BOUML community is forming up)

Solution 3

phUML

phUML is fully automatic UML class diagramm generator written in PHP, licensed under the BSD license. 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.

UML Example

./phuml -r /var/www/my_project -graphviz -createAssociations false -neato out.png

Step by step guide

Solution 4

the best (Windows) software i have found to do PHP and UML is Sparx Systems Enterprise Architect. besides a pletora of features, it supports the following for PHP:

  • Reverse engineer object oriented PHP into UML class diagrams
  • Generate PHP class definitions from UML class diagrams
  • Synchronize changes made in a UML class into the corresponding PHP class definition
  • Synchronize changes made in a PHP class definition into the corresponding UML class
  • Create UML sequence diagrams to show what PHP classes use and how they are used
  • Produce detailed documentation of your PHP code in standard RTF and HTML format
  • Perform code engineering on models to generate base PHP pages.

not free ($199), but definitely worth the money.

Solution 5

Have you tried Autodia yet? Last time I tried it it wasn't perfect, but it was good enough.

Share:
153,971

Related videos on Youtube

Jeffrey04
Author by

Jeffrey04

Formerly a webdev, then a failed postgrad, now shifting focus to more data and maths projects

Updated on July 08, 2022

Comments

  • Jeffrey04
    Jeffrey04 almost 2 years

    How do I generate UML diagram based on existing classes in PHP?

    • Jeffrey04
      Jeffrey04 over 6 years
      I don't work with PHP anymore, so I don't have code to actually test out. When I posted this none of the initial answers were doing enough, but a lot has changed since then. I was working with PHP 5.2, and it is now PHP7 these days.
  • Jeffrey04
    Jeffrey04 over 15 years
    i tried autodia but somehow i cant generate accurate class diagram (php5)
  • Stephen Fuhry
    Stephen Fuhry over 14 years
    for some reason, pear.com doesn't like that link without a trailing slash: pear.php.net/package/PHP_UML
  • nickf
    nickf over 14 years
    @Stephen, yeah I noticed that too! If you click the link, it gives you a 404, but if you select the address bar and press enter, it works.
  • Sk8erPeter
    Sk8erPeter almost 13 years
    Wow, that's a really useful and professional program indeed, thanks for the tip!! I just tried the UML class diagram generating with the Sparx EA's reverse engineering method from PHP source code, and it worked like a charm, I was shocked how fine this worked. :D As our projects are growing bigger and bigger, and we create more and more objects, it's getting harder to keep an eye on our own code, but it's a great help in it, as it generates the UML diagrams the right way (of course, maybe exceptions may occur) AFTER we finished the code. This even helps to simplify relations between objects.
  • MPV
    MPV almost 13 years
    The web page for BOUML now states: "CAUTION: Due to the continuous license violations, attacks and insults from people of wikipedia [...], I have decided to stop work on Bouml except to fix bugs."
  • Imran Omar Bukhsh
    Imran Omar Bukhsh over 12 years
    @MPV - i am able to install it from the Ubuntu Software Center
  • Val Redchenko
    Val Redchenko over 12 years
    "[December 18, 2011] Downloads are suspended until further notice" from their official web site. http://bouml.free.fr/download.html - this is because I needed a version for Win7. I imagine it may still be available from Ubuntu repositories - need to check
  • Shiplu Mokaddim
    Shiplu Mokaddim about 12 years
    @ValRedchenko BOUML 5.0.1 Released on February, 22th 2012. Its still available.
  • JDelage
    JDelage almost 12 years
    @ax - I'm a newbie, and I get a bit lost in their list of features (under "compare editions"). What would be the name of the feature that allows me to enter PHP code (or link to PHP files), and get a diagram in return? Trying to figure out which version I might need.
  • Andrew Ensley
    Andrew Ensley over 11 years
    Version 6.1 released September 23, 2012. Appears development has picked up again. No notice about slowing down, stopping, etc. bouml.fr/historic.html
  • Ben
    Ben over 10 years
    A few years later command is now pear install PHP_UML-1.6.1 (see pear.php.net/package/PHP_UML/download/All or pear.php.net/package/PHP_UML)
  • Admin
    Admin over 10 years
    requires SVN/subversion to download and doesn't really say what the license of the source code is, but it looks good! yah I would be careful at looking at the source code there's absolutely no license on it and the only readme is on the site I think
  • Anthony Hatzopoulos
    Anthony Hatzopoulos over 10 years
    The license is linked right there in the project's website sidebar, under the author, Creative Commons: creativecommons.org/licenses/by-nc-sa/3.0
  • Admin
    Admin over 10 years
    that's the license for the content of the site, the LICENSE for the project must be included with the project itself.
  • Anthony Hatzopoulos
    Anthony Hatzopoulos over 10 years
    I sent an email to the author, Jakob and he responded with an update to the repository with a clear and cut 3-clause bsd License
  • Impulss
    Impulss over 10 years
    I downloaded this and got it to work after a bit of tinkering. Was really quite nice, except I can't get the associations to work, but I'm sure i'll figure it out. Nice, simple. No GUI though, but not that big of a deal.
  • Anthony Hatzopoulos
    Anthony Hatzopoulos over 10 years
    I like the dot output style which places all objects linearly instead of star (neato) shape with associations on the entire project class folder: ~/phuml/app/phuml -r ~/path_to_your/classes/ -graphviz -createAssociations true -dot ~/output_folder/test_dot.png
  • Mikko Rantalainen
    Mikko Rantalainen about 10 years
    The original by Jakob Westhoff has been removed from his site; I found a fork at github.com/greenantdotcom/phUML
  • Anthony Hatzopoulos
    Anthony Hatzopoulos about 10 years
    @MikkoRantalainen The official github repo is github.com/jakobwesthoff/phuml (I've updated the answer)
  • D.A.H
    D.A.H almost 9 years
    True, but life is a more complicated than some principles, which are wise to use. You might need to compare actual code against the original UML diagram, or analyse someones code or some some code, which was implemented without UML diagrams.
  • Dariux
    Dariux almost 8 years
    Installed 1.6.2 version, but getting error: 'phpuml' is not recognized as an internal or external command,
  • Basil Musa
    Basil Musa about 7 years
    Disagree. Great value gained from visualizing a code base/module with a diagram. Code is like street directions, but with too many directions sometimes one might find a map useful.
  • Basil Musa
    Basil Musa about 7 years
    Does not visualize dependencies, only inheritance.
  • DevWL
    DevWL about 7 years
    not working with php 7
  • u2107680007911543774e7r
    u2107680007911543774e7r about 7 years
    @DevWL: That's not all that surprising - the author/maintainer might be happy receive assistance in getting it to work with PHP 7, if you're feeling generous.
  • Mikko Rantalainen
    Mikko Rantalainen about 6 years
    Most UML drawing programs have such a bad UI that it's faster to write the code and generate the UML diagram automatically, even if you then throw away the code that you used to generate the diagram...
  • unifreak
    unifreak about 5 years
    The documentation is horrible, I never figured out how to generate a single diagram. Maybe you can write a tutorial on this