Use php class diagram drawing tool -- phuml to build the class diagram of the project

Source: Internet
Author: User
Tags autoload svn client collabnet

Use php class diagram drawing tool -- phuml to build the class diagram of the project

Yesterday, I occasionally searched for the tools used to create UML class diagrams on the Internet. I was planning to create a class diagram for the statusnet project myself (maybe I should have underestimated the workload ), so I got a windows version of VP_suite 4.2 and tried it quite well, and the interface was quite good. Then I thought there should be something to make php source code into a class graph. I searched the internet and found it -- phUML (today's main character )! In the process, we also found a phpjavasentor tool that can turn the code into a good documentation (I will introduce it to you later ). Because I was about to leave work yesterday, and the director was on duty, I was too embarrassed to leave very late, so I didn't try to study it in one breath. After a day of repeated attempts, I finally got OK!

First, you must have an SVN client to download phUML. This open-source project is maintained on SVN. Check whether the SVN client is installed in your linux: The following is my fedora12 output.

[Root @ xiaofei ~] # Svn -- version
Svn, version 1.6.5 (r38866)
Compiled on Sep 19 2009,11: 02: 40

Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/site.
This product contains software developed by CollabNet (http://www.Collab.Net.

You can use the following versions to access the module:

* Ra_neon: the module that uses neon to access the version library through the WebDAV protocol.
-Handling the "http" Scheme
-Handling the "https" SOLUTION
* Ra_svn: the module that uses the svn network protocol to access the version library. -Use Cyrus SASL for authentication
-Handle the "svn" SOLUTION
* Ra_local: access the version library module of the local disk.
-Process the "file" SOLUTION
I have installed SVN. If it is not installed, you can use yum install svn. Then download the phUML project:

[Root @ xiaofei ~] # Svn checkout svn: // svn. pureenergy. cc/phuml

A phuml/src
A phuml/src/app
A phuml/src/app/phuml
A phuml/src/exceptions
A phuml/src/exceptions/processor
A phuml/src/exceptions/processor/notFound. php
A phuml/src/exceptions/processor/graphviz
A phuml/src/exceptions/processor/graphviz/style
A phuml/src/exceptions/processor/graphviz/style/notFound. php
A phuml/src/exceptions/processor/externalExecution. php
A phuml/src/exceptions/processor/option. php
A phuml/src/exceptions/phuml
A phuml/src/exceptions/phuml/invalidprocessorchain. php
A phuml/src/exceptions/phuml/invalidprocessor. php
A phuml/src/exceptions/Generator
A phuml/src/exceptions/Generator/notfound. php
A phuml/src/exceptions/base
A phuml/src/exceptions/base/property. php
A phuml/src/interfaces
A phuml/src/interfaces/processor
A phuml/src/interfaces/processor/externalcommand. php
A phuml/src/interfaces/processor/graphviz
A phuml/src/interfaces/processor/graphviz/style. php
A phuml/src/interfaces/processor. php
A phuml/src/interfaces/generator. php
A phuml/src/config
A phuml/src/config. php
A phuml/src/scripts
A phuml/src/scripts/checkall. Sh
A phuml/src/autoload
A phuml/src/autoload/phuml_autoload.php
A phuml/src/autoload/php_autoload.php
A phuml/src/autoload/base_autoload.php
A phuml/src/autoload/processor_autoload.php
A phuml/src/autoload/structure_autoload.php
A phuml/src/classes
A phuml/src/classes/processor
A phuml/src/classes/processor/graphviz. php
A phuml/src/classes/processor/Statistics. php
A phuml/src/classes/processor/options. php
A phuml/src/classes/processor/graphviz
A phuml/src/classes/processor/graphviz/style
A phuml/src/classes/processor/graphviz/style/default. php
A phuml/src/classes/processor/graphviz/options. php
A phuml/src/classes/processor/dot. php
A phuml/src/classes/processor/neato. php
A phuml/src/classes/base. php
A phuml/src/classes/generator
A phuml/src/classes/generator/tokenparser. php
A phuml/src/classes/php
A phuml/src/classes/php/interface. php
A phuml/src/classes/php/attribute. php
A phuml/src/classes/php/class. php
A phuml/src/classes/php/function. php
A phuml/src/classes/PHP/functionparameter. php
A phuml/src/classes/phuml. php
Retrieve version 69.
My current user is root, so the project I downloaded has been saved to the/root/phuml directory.

I don't seem to know how to run the project code and how to install it, which makes me very headache. I even thought that the project developer Jakob Westhoff wrote an email for help. I am a PHP newbie, and I am not very familiar with the command line PHP. This is a huge discount. Later, I found almost no information about the use of phuml on the Internet. Later, I tried to run the phuml file using the php Command Line. The result is correct.> _ <

You can use the following command to obtain the location of your php Command Line, which is usually the/usr/bin/php Command.

[Root @ Xiaofei bin] # Which PHP
/Usr/bin/PHP
Next, you can try to run the command line with phuml

[Root @ Xiaofei app] # PHP/root/phuml/src/APP/phuml-H
PHP warning: module 'mbstring' already loaded in unknown on line 0
Phuml version 0.2 (Jakob Westhoff <jakob@php.net>)
Usage: phuml [-H |-L] [Options] <directory> <processor> [processor options]... <OUTFILE>

Commands:
-H Display this help text
-L List all available processors

Options:
-R Scan given directorie recursively

Example:
Phuml-r./-graphviz-createAssociations false-neato out.png

This example will scan the current directory recursively for php files.
Send them to the "dot" processor which will process them with the option
"CreateAssociations" set to false. After that it will be sent to the neato
Processor and saved to the file out.png
You should be very excited to see this. It is only a step away from success. The help information above can help you a lot !!

Use this command to experiment: (Note the directory of the execution file of the cd to phpmul, that is,/root/phuml/src/app, the same below)

[Root @ xiaofei app] # php phuml-r./-graphviz-createAssociations false-Neato out.png
PHP Warning: Module 'mbstring' already loaded in Unknown on line 0
PhUML Version 0.2 (Jakob Westhoff <jakob@php.net>)
[|] Running... (This may take some time)
[|] Parsing class structure
[|] Running 'graphviz' processor
[|] Running 'neato 'processor
Sh: neato: command not found
A fatal error occured during the process:
Execution of external program failed:
Array
No, it's wrong. What's the problem? Didn't I install neato? Detected:

[Root @ xiaofei app] # php phuml-l
PHP Warning: Module 'mbstring' already loaded in Unknown on line 0
PhUML Version 0.2 (Jakob Westhoff <jakob@php.net>)
The following processors are available:

* Processor: Graphviz
-Options:
Style (string ):
Style to use for the dot creation

CreateAssociations (boolean ):
Create connections between classes that include each other. (This
Information can only be extracted if it is present in docblock comments)

* Processor: Neato
-Options:
This processor does not have any options.

* Processor: Dot
-Options:
This processor does not have any options.

* Processor: Statistics
-Options:
This processor does not have any options.

As mentioned above, The following processors are available: and there is also The Neato subprogram. Here I have been stuck for a long time. After a long time of thinking, I thought it was Neato that should be followed by a parameter or something, I have read many instruction documents about Graphviz (Graphviz in phUML) to complete drawing. Suddenly I realized that Graphviz may not be installed !!!

So install:

[Root @ xiaofei app] # yum install graphviz
Loaded plug-in: refresh-packagekit
Adobe-linux-i386 | 951 B 00:00
Updates/metalink | 6.8 kB: 00
Set the installation process
Resolve Dependencies
--> Execute transaction check
---> The software package graphviz. i686. 20.3-5. fc12.1 will be upgraded
--> Complete dependency Calculation

Dependency Solution

========================================================== ========================================================== ====================
Package architecture version repository size
========================================================== ========================================================== ====================
Installing:
Graphviz i686 2.20.3-5. fc12.1 fedora 766 k

Transaction Summary
========================================================== ========================================================== ====================
Install Package 1
Update 0 Software Package

Total downloads: 766 K
Are you sure you want? [Y/n]: Y
Download the software package:
Graphviz-2.20.3-5.fc12.1.i686.rpm | 766 kb 00:01
Run rpm_check_debug
Execute transaction Test
Complete transaction Test
Transaction test successful
Execute transactions
Installing: graphviz-2.20.3-5.fc12.1.i686 1/1

Installed:
Graphviz. i686. 20.3-5. fc12.1

Finished!

Run again

[Root @ xiaofei app] # php phuml-r./-graphviz-createAssociations false-Neato out.png

It will work properly.

If you want to draw a class chart for some PHP files, replace the above./with the position of your PHP program.

I started to draw the statusnet class diagram and an error occurred.

[Root @ xiaofei app] # php phuml-r/var/www/html/blog/-graphviz-createAssociations false-Neato out.png
PHP Warning: Module 'mbstring' already loaded in Unknown on line 0
PhUML Version 0.2 (Jakob Westhoff <jakob@php.net>)
[|] Running... (This may take some time)
[|] Parsing class structure
[|] Running 'graphviz' processor
[|] Running 'neato 'processor
Neato: failure to create cairo surface: out of memory
A fatal error occured during the process:
Execution of external program failed:
Array

Memory leakage? It is estimated that there are too many classes in statusnet, and phml is overloaded. There is no way to draw class diagrams with only one directory and one directory. The images are too big to be uploaded to the blog. Let's just draw them out!

Yuchao @ yuchao-MS-7597 :~ /Source/phuml/src/app $ php phuml-r/home/yuchao/source/latest/piwik-graphviz-createAssociations false-Neato out.png
PhUML Version 0.2 (Jakob Westhoff <jakob@php.net>)
[|] Running... (This may take some time)
[|] Parsing class structure
[|] Running 'graphviz' processor
[|] Running 'neato 'processor
[|] Writing generated data to disk

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.