Command line interface

Command line interface – How to run PHP_UML from the command line?


The executable 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.


Pass the files and/or the directories to parse as arguments:

$ phpuml /var/www/foo

Separate the different elements by a space:

$ phpuml /var/www/file1.php file2.php

By default, 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 option -n:

$ 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 -o:

$ phpuml /var/www/foo -n MyProject -o /var/tmp/
This will parse /var/www/foo, and save the XMI data to /var/tmp/MyProject.xmi. Use the dot to save to the current directory: -o .

The option -o also accepts a file name, instead of a directory path.

Generating PHP code or HTML API documentation

In addition to xmi, 2 output formats are also available: html, and php. They work by applying an XSL transformation to the XMI data (in UML version 2).

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 a full HTML documentation in /var/tmp/.

If you need to provide your own XMI file, instead of parsing existing 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 /var/tmp/.

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 -x:

$ 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 automatically converts UML/XMI data in 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, converts it to version 2, and stores it in foo2.xmi. 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

By default, 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 php and txt files.

Other options are available (like an option to exclude certain files or directories to parse). You will discover them all by asking for help, like this:

$ phpuml -h

Introduction (Previous) API (Next)
Last updated: Tue, 02 Jun 2009 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

Note by: schkovich
Following command line options and switches are available:
-o directory
-f format, --format=format
-x XMI version
-n name
-e encoding
-i pattern, --ignore=pattern
-m pattern, --match=pattern
-l errorLevel, --error-level=errorLevel
-h, --help
-v, --version