PHP_UML converts programming data from one format (PHP or XMI) to another (PHP, XMI or HTML). In other words, PHP_UML is a reverse-engineering tool, and an API documentation tool.
It can parse PHP files, and generate:
From its version 1.5, PHP_UML can also parse procedural code. The export format called "htmlnew" benefits from this new capability, and turns PHP_UML into a kind of competitor of PhpDocumentor (although it does not offer all of its features). See here an example of an API documentation as generated by PHP_UML.
PHP_UML is able to parse the following PHP elements: namespaces, classes, interfaces, properties, and functions. It can also retrieve information from the inline comments, via the annotations:
@varlearn PHP_UML about the expected types of a parameter or a property (when type hinting is not present).
@packagelearns PHP_UML about the namespace of an element (even if, from PHP 5.3, it is recommended to use the PHP namespacing instructions instead)
So the more documented your PHP code is, the more precise your XMI file, or your API documentation, will be.
You can use PHP_UML either from command line (the simplest solution), or by writing a piece of code that relies on PHP_UML.
Parsing a single file
test.php, and generating its XMI file:
$uml = new PHP_UML();
$uml->setInput('tests'); // this defines which files/folders to parse (here, the folder "tests")
$uml->parse('myApp'); // this starts the parser, and gives the name "myApp" to the generated metamodel
$uml->export('xmi', 'myApp.xmi'); // this serializes the metamodel in XMI code, and saves it to a file "myApp.xmi"
At the current time, the UML/XMI standards exist in two distinct families of versions, 1.x and 2.x. PHP_UML can generate XMI in version 1.4, as well as in version 2.1. Be warned, though, that some UML tools might not interpret accurately the data contained in your XMI file. For example, the link between a UML artifact (a source file) and the classes defined inside that artifact is only available from version 2 of UML.
PHP_UML can also convert existing UML/XMI data from version 1.4 to version 2. An inline converter (using PHP_UML behind the scene) is available here.