Generate UML from PHP code

Asked

Viewed 989 times

6

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

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

  • Man, take a look at this BOUML, never used but I believe it can help you.

  • The bad thing about this BOUML is you get paid

  • There are several options on the Internet. rs http://www.phpclasses.org/package/6025-PHP-Generate-UML-diagrams-from-PHP-code-using-GraphML.html

  • You can use 'Case UML'. It can support PHP and other programming language. You can visit the website for more information: https://www.visual-paradigm.com/solution/free-use-case-tool/? gclid=EAIaIQobChMInarEk-mu4AIVjByGCh1knwaREAAYASAAEgKgJPD_BwE

1 answer

3

You can use the PHP_UML

  • Allows generating UML/XMI files version 1.4, or 2.1
  • Generates an 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

PEAR is required to install via command line. If you do not have it install and then run on the terminal:

pear install pear/php_uml

To generate via terminal just use the command

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

In the following example, PHP_UML will go through all the 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 the documentation

Another way to generate is to create using the 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 in API documentation

Browser other questions tagged

You are not signed in. Login or sign up in order to post.