Use PHP_UML to generate a UML diagram of the code

Source: Internet
Author: User
Tags xmi file
When reading other people's code and without detailed documentation, how to quickly see the entire code structure (class structure) becomes a real problem. today I will introduce a method for automatically generating UML diagrams.

When reading other people's code and without detailed documentation, how to quickly see the entire code structure (class structure) becomes a real problem.

Today I will introduce a method for automatically generating UML diagrams.

Suppose that I have a project folder: laruence, which has a file Root. php (in fact, no matter how many levels of directories, multiple files ).

 
 
  1.  
  2. abstract class Root {
  3.     private $instance;
  4.     abstract public function Hi();
  5. }
  6.  
  7. interface Intro {
  8.     public function Say();
  9. }
  10.  
  11. class Sub extends Root implements Intro {
  12.     private $instance;
  13.     public function Say() {
  14.         echo "I am Laruence";
  15.     }
  16.     public function Hi() {
  17.         echo "Hello!";
  18.     }
  19. }
  20. ?>

First, we need to use PHP_UML (PHP_UML) to generate XMI based on the code.

The usage is relatively simple. after installing PHP_UML, run:

 
 
  1.  phpuml laruence/ -o laruence.xmi -n laruence -f xmi --pure-object --no-deployment-view --no-component-view --no-docblock

You will get a laruence. xmi file. you can learn the specific parameters of phpuml through phpuml-help.

With xmi, how can we convert it into a UML diagram?

Visio2007 does not support importing XMI. I found another tool: Altova Umodel, which supports conversion from XMI to UML diagrams and needs to be registered, however, a 30-day license is provided (if you have a better replacement solution, please add it ).

After Umodel imports laruence. xmi, a UML diagram is generated and the following PNG is obtained:

UML diagram

Is it convenient?

In addition, PHP_UML can also generate html format, which is also good for a doc gen tool. you can also generate php files through xmi.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.