Generate UML of PHP code

4

Is there any software, preferably opensource, that manages the UML of a code already written in PHP?

The annoying thing is having to update the diagram every time the code is updated.

    
asked by anonymous 26.03.2014 / 04:43

2 answers

2

Dude, take a look at this BOUML , I have never used it but I think it can help.

    
26.03.2014 / 06:21
2

You can use PHP_UML

  • Allows you to generate UML / XMI files version 1.4, or 2.1
  • Generate HTML documentation
  • Can generate PHP code skeletons based on a UML / XMI file
  • Can convert UML / XMI files from version 1.4 to 2.1

To install via the command line you need PEAR. If you do not have install and then run the terminal:

pear install pear/php_uml

To generate the terminal path, simply use

phpuml [INPUT] -n [PROJECT NAME] -o [OUTPUT LOCATION] -f [OUTPUT FORMAT]

In the following example, PHP_UML will go through all files in /var/www/foo and export the file /var/tmp/MyProject.xmi naming the project as MyProject.

phpuml /var/www/foo -n MyProject -o /var/tmp/

For more command check documentation

Another way to generate is to create use API creating a PHP script. For example:

// Seta o caminho padrão de inclusão de arquivo como sendo a pasta do PEAR
set_include_path( '/usr/lib/php/pear/' );
require_once __DIR__ . '/uml/UML.php';

$uml = new PHP_UML();   
// Define qual pasta ou arquivos serão parseados
$uml->setInput('/var/www/foo');
// Realiza o parser e seta o nome do projeto como MyProject
$uml->parse('MyProject');
// Ignora alguns arquivos que contenha um padrão de nome
$uml->setIgnorePatterns('.svn');
$uml->export('xmi', '/var/tmp/');

See more examples on API documentation

    
02.04.2014 / 02:26