phpuml relies on Console::CommandLine.
If you have followed the normal PEAR installation process to install PHP_UML, that dependency should have been resolved, and you should be able to run
phpuml directly from the command line.
PHP_UML converts data into another kind of data. This can be summarized with:
$ phpuml [INPUT] -o [OUTPUT LOCATION] -f [OUTPUT FORMAT]
In other words, to specify the files/directories to scan, pass them as main arguments:
$ phpuml /var/www/foo
Separate the different elements by a space:
$ phpuml /var/www/file1.php file2.php
phpuml will recursively parse the specified files/folders, and will echo the XMI code on the screen (UML/XMI version 2).
Renaming the UML model name
By default, the root package of a UML model is named default. To rename it, use the switch
$ phpuml /var/www/foo -n MyProject
Saving to a file
To save the XMI data in a particular place, instead of printing it on the screen, use
$ phpuml /var/www/foo -n MyProject -o /var/tmp/
This will parse
/var/www/foo, and save the XMI data to
Use the dot to save to the current directory:
-o also accepts a file name, instead of a directory path.
Generating an API's documentation in HTML, or some PHP code
In addition to xmi, 3 output formats are also available: html, htmlnew, and php.
Use the option
-f to specify which format you want
phpuml to generate.
$ phpuml /var/www/foo -f html -o /var/tmp/
This will scan
/var/www/foo, and create the API documentation in
If you need to provide your own XMI file (instead of parsing existing PHP files), simply pass it as argument.
$ phpuml myFile.xmi -f php -o /var/tmp/
This will read the XMI code contained in
myFile.xmi, and generate the PHP code templates in
Note that with the command line tool, you cannot both read an XMI file and parse PHP files: you will have to use the API if you need to build
a UML model by merging inputs from XMI and PHP simultaneously.
Selecting the UML/XMI version
To select which version of the UML/XMI standards you want your XMI to be written in, use the option
$ phpuml /var/www/foo -x 1 -o /var/tmp/
Note that Argouml accepts XMI code only in version 1, while the Eclipse plugins (Ecore standard) only in version 2.
Converting from UML/XMI version 1 to 2
phpuml can automatically convert UML/XMI data from version 1.4 to version 2.1.
$ phpuml foo1.xmi -o foo2.xmi
This will read
foo1.xmi, and, if its XMI content is in version 1.x, converts it to version 2, and stores it in
Note that this is an ad hoc conversion, inspired on what Rationale Rose, Argouml and Umbrello generate. It does not convert all of the UML entities, and it does not interpret all of the various XMI dialects.
Filtering the files to parse
phpuml will parse only files with the extension
.php. To modify this file pattern, use the
- m selector:
$ phpuml /var/www/foo -m *.php *.txt
This will parse all
Ignoring some files and folders
Use the switch
$ phpuml /var/www/foo -i tests *.php4
This will parse all files, except the ones in the folder "tests", and the ones with an extension "php4".
Removing the dollar sign ($) in the documentation
Use the switch
$ phpuml /var/www/foo --no-dollar -o foo.xmi
Other options are available. You will discover them by asking for help, like this:
$ phpuml -h
Form more information about how PHP_UML interprets your PHP code, read this section.