PHP_UML

Abstract

PHP_UML is a reverse-engineering tool, and a documentation tool.

Practically, with PHP_UML, you can feed a modelling design tool, like Rational Rose or Argouml, with an UML representation of existing PHP source code. This way you get an immediate overview of an application, with all the usual functions of a software design tool, like class diagrams exportation, refactoring of object-oriented applications, or automatic code generation.

PHP_UML is three parts :

What does it generate ?

PHP_UML generates a logical view (composed of the packages and classes found), a component view, and a deployment view (a mapping of the physical filesystem). Other UML elements will be available in future releases.

Usage

PHP_UML does not provide any graphical interface, although PhpDocumentor could easily been interfaced with it.

First, let's create a PHP_UML object:

$p = new PHP_UML;

Then, let's parse recursively a directory:

$p->parseDirectory('.'); // we will parse the current directory

Now, we run the XMI generation:

$p->generateXMI(1); // we choose XMI version 1 (version 2.1 is also available)

We save the resulting XMI code somewhere:

$p->saveXMI('my_XMI_file.xmi');

That's done ! You can now import my_XMI_file.xmi into your favourite UML design tool !

Other options are available, see the documentation enclosed in the PEAR Package.

Source code and download

PHP_UML is a PEAR package. Use the PEAR installer to install it properly on your system.

Alternatively, you can download it from Sourceforge.

Features

What can I do with PHP_UML ?

You can parse directories of PHP code, and get an XMI file containing all the packages/classes found. You can import that XMI file into an UML modeling design tool, and get a logical view (your packages/classes/interfaces...) as well as a component and/or deployment view (files are mapped to artifacts and/or components, and directories are mapped to subsystems and/or packages).
The relationship between a particular class and the PHP source file where it is defined (that is, an artifact in a deployment view) is rendered through UML2 manifestations. If your UML CASE tool is UML2 compatible, it should create the association between the class and the artifact correctly.

Technical questions

Read here for more details about the internal implementation.

Read here for a discussion about packages and namespaces management in PHP_UML.

Tools compatible with PHP_UML

MOF/UML/XMI are complex standards, and they have changed a lot from version 1 to 2.
Depending on the UML software you are going to use along with PHP_UML, some aspects of your XMI might be interpreted differently, or even ignored.
You may have to disable some options (in PHP_UML, or in your software) for the import to work.

Note: class diagrams are generally not automatically generated by modeling programs. You will have to manually drag and drop your classes (from the class tree view) into a blank class diagram.

Todo list

Depending on the class:

Links

Baptiste Autin, April 2008