API

API – How to use PHP_UML from its API?

Principles

PHP_UML is structured in 5 packages:

  • The main package, which contains the main class (PHP_UML) and some utility classes

  • The PHP package, where the PHP parser resides

  • The Metamodel package, which contains the data structures that PHP_UML is using to modelize the code parsed

  • The XMI package, which contains classes that can serialize a metamodel into XMI code

  • The Output package, which contains all the stuff to transform XMI into another format (like HTML)

But the only class you need to know about is PHP_UML. Since the first release of the package, the API of that class has changed a little bit, and you will find several methods doing more or less the same job.

Examples

Parsing of a single file test.php, and generation of its XMI file:

<?php
require_once 'PHP/UML.php';

$uml = new PHP_UML();   
$uml->setInput('test.php');
$uml->parse('foo');           // parses, and sets the name of the root package
$uml->generateXMI(1);         // generates XMI in version 1
$uml->saveXMI('test.xmi');
?>

Note that, since UML is a strong object-oriented standard, PHP_UML ignores all global functions, or global constants.

Parsing of two directories, ignoring the CSV folders, and generation of HTML documentation

<?php
require_once 'PHP/UML.php';

$uml = new PHP_UML(); 
$uml->setInput(array('C:\Inetpub\foo''C:\Inetpub\libraries'));
$uml->parse();
$uml->generateXMI(2);
$uml->export('html''C:\Inetpub\api');
?>

Import of a XMI file, and generation of PHP code templates

<?php
require_once 'PHP/UML.php';

$uml = new PHP_UML();   
$uml->readXMIFile('foo.xmi'); 
$uml->export('php''C:\Inetpub\foo');
?>
Command line interface (Previous) Conversion rules (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:

There are no user contributed notes for this page.