Command line interface

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

Install

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.

Arguments

PHP_UML converts data into another kind of data. This can be summarized with:

$ phpuml [INPUT] -o [OUTPUT LOCATION] -f [OUTPUT FORMAT]
  • [INPUT] can be PHP files, or XMI files. [OUTPUT FORMAT] can be PHP files, XMI files, or HTML files.

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

By default, phpuml will recursively parse the specified files/folders, and will echo the XMI code on the screen (UML/XMI version 2).

Options

Renaming the UML model name

By default, the root package of a UML model is named default. To rename it, use the switch -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 an API's documentation in HTML, or some PHP code

In addition to xmi, 3 output formats are also available: html, htmlnew, and php.

  • "htmlnew" is a full XHTML-compliant API documentation ("modern" look and feel). It has the particularity to reflect the procedural code, in addition to the object code. The global procedural functions and constants appear in the top package.
  • "html" is another HTML API documentation ("Javadoc" look and feel)
  • "php" is a PHP code generation (code skeletons)

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 /var/tmp/.

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 /var/tmp/. 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 -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 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 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.

Ignoring some files and folders

Use the switch -i:

$ 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 --no-dollar:

$ 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.

Purpose and simple usage example (Previous) Things to know about how PHP_UML parses PHP code (Next)
Last updated: Sun, 27 Jul 2014 — 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
--no-deployment-view
--no-component-view
--no-dollar
--no-docblocks
--show-internal
--only-api
-i pattern, --ignore=pattern
-m pattern, --match=pattern
-l errorLevel, --error-level=errorLevel
--pure-object
-h, --help
-v, --version