📜 ⬆️ ⬇️

Creating UML with existing PHP code

When most projects have long been at the stage of support, rather than development, the maintenance of documentation in its current form is often not carried out. Then it will be quite useful to get a UML diagram from the existing code. This is also necessary if the pre-project documentation was not fully maintained or not all parts of the system were designed. The question is especially relevant when a new developer appears.

In this article I will review 2 scripts implemented in PHP:

Php2xmi console script


An interesting, in my opinion, implementation of the UML model creation mechanism is the php2xmi console script, which is written in more detail here .

What is interesting this option:
The main disadvantages are:
An example of a file for generating a model of the Zend_Config class:
<?php
require_once 'Zend/config.php';
require_once 'Zend/Config/ini.php';
require_once 'Zend/Config/xml.php';
require_once 'Zend/exception.php';
require_once 'Zend/Config/exception.php';

* This source code was highlighted with Source Code Highlighter & me.

To generate models of existing projects, you can add __autoload support to this script.
')
Conclusion: this script allows to obtain a diagram of existing classes without additional efforts. The fact that it is written in PHP allows you to edit it to any developer on your own.

PHP_UML library


Another way to create UML diagrams for existing code. It is also a tool implemented by PHP tools, but unlike the previous one it is already a library for creating models. You can start by reviewing the examples that are included in the archive .

There is also the main documentation describing the capabilities. I will highlight the main and my most important and interesting ones:
The main disadvantages are:
By the date of the last update - August of this year - we can say that the project continues to develop and is more promising. In addition to this option, you can also add the fact that it is covered with Unit tests, which will facilitate understanding of the principles of its work and possible subsequent development. It is also included in the PEAR package library, which over time retains only quality solutions.

Conclusion: compared to the php2xmi script, this project looks more professionally executed, so you should pay more attention to studying it.

Source: https://habr.com/ru/post/44306/


All Articles