Generation of Class Diagram from XMI
Asked Answered
L

2

10

Situation

I have a PHP project with lots of classes with lots of relationships in lots of folders following the Zend Naming Convention.

I use the NetBeans IDE 7.1. I work under Windows 7.

Goal

I need to see a graphical representation of the class relationships, possibly in varying depths and varying degrees of complexity. Also, it would be nice if the classes in the diagram are clickable. I do not necessarily need to generate documentation.

Attempts

1. Within NetBeans

NetBeans is an awesome IDE with lots of features. In fact, it recognizes class dependencies, and it would be wise to assume that it has some sort of way to graphically view this relationship, natively, or through a plugin. Such a plugin exists, but is for version 5.5. I have 7.1, and it's not compatible. Fail.

2. Enterprise Architect

A simple google search brings up Enterprise Architect as an all-capable, completely comprehensive tool for solving such problems. So, I download and install. I'm not going to go to the detail of how I couldn't understand how to do anything, and how the tutorials are bragging about what the software can do, but rarely say how.

So, I imported the source. It generated many different classes and parsed all the members. Also, it generated the class diagrams. "Perfect!", I though, but alas. The class diagrams only show relationships between classes, the files of which were in the same source folder, despite the relationships being visibly registered in the classes' properties. A search for documentation on how I could merge all these diagrams into one was unsuccessful. Fail.

NOTE: I created a parallel thread before this one here.

3. PHP_UML

Found this PEAR tool. Looked good. So, I read through documentation on how to install it for my setup from various sources, and ran it. First, I used the html output format. Great! Lots of documentation with an index, bla bla bla. However, the best it could do in the direction I want was this: Class Diagram? Needless to say, I guess, that this is a very poor, super simplified version of what I actually need. Conclusion: fail.

4. Enterprise Architect + PHP_UML

However, PHP_UML can also generate XMI. Wow. Very nice. I can store my relationships and view them in different ways and exchange with other people.

So, I imported it into Enterprise Architect. Result: same as before with Enterprise Architect alone, only no class diagrams. Just the classes. As far as I've read about it, I can now manually create the relationships. Epic fail.

5. ArgoUML + PHP_UML

Somewhere through my search for solution I stumbled upon someone's comment that said they use ArgoUML. Downloaded and installed. XMI imported with some hassle (had to change version explicitly to 1). Fail (see Attempt 3).

Conclusion

Such a seemingly trivial task, and yet, so difficult. Do I have to go through this whole list, trying out each application?

Lectureship answered 25/9, 2012 at 19:46 Comment(5)
These are four different questions, only two of which are to do with XMI. StackOverflow questions and answers are intended to form a repository where others can find solutions to the same problem down the line. Please split this question into one for each tool, and I'll answer the one about EA.Blaeberry
I already told you in your (rather duplicate) question that you can also just take Phpstorm to generate that. Also this question sounds more like a rant which is not helpful. If you need to use Netbeans, you should file a feature request (one I think that is related was closed because there is no interest in doing that, so you just might have choosen the wrong product if you're not flexible or competent enough to use other, exisiting tools).Fuselage
Hakra, There are no "four different questions". I have stated what I need in the "Goal" section. The "Attempts" section lists what I have done, so that there are no identical suggestions.Lectureship
I'm the one who said it's four different questions, and I stand by that. The first two are nothing to do with XMI, as the title suggests. The fact that you can't add all relevant tags to the question is also a very clear indication that it sprawls over too many different subjects. I understand your frustration, but please accept that this is not a discussion forum with conversational threads, it is a Q&A site where both questions and answers should be relevant to others (stackoverflow.com/questions/how-to-ask), and the best way to achieve that is to keep them specific.Blaeberry
Uffe, I don't understand where you see 4 different questions. Attempts illustrate how I arrived to where I am now. The question is: I want to generate a class diagram from source. Right now, I have an XMI file, and I want to generate the diagram from that, just as the title of the question indicates.Lectureship
L
5

One of the ways to do this would be to take the approach illustrated in my attempt 2 or 4, and then follow instructions given here for Enterprise Architect.

To generate an XMI file using PHP_UML:

  • Follow these instructions to install PEAR if not installed already, if you have PHP installed separately.
  • If you are using XAMPP under Windows (my case), follow these instructions to add PEAR to the PATH env variable and thus make PEAR available through CMD, and to learn how to install packages in both *nix and Windows systems. Hint: the PATH separator is ";" (semicolon) for Windows.
  • In some setups, like if using XAMPP, you may need to activate the XSL extension. In this case, open your php.ini file (you may need Administrator privileges to save it), and uncomment or add the following line to the bottom of the "Dynamic Extensions" section: extension=php_xsl.dll.
  • Install the PHP_UML package with pear install PHP_UML.
  • Execute phpuml -f xmi -o name_of_output_dir. If you're planning to use the generated XMI with some older programs later, you may need to specify XMI version 1 by adding -x 1.
  • For me, this did not work immediately, saying that I am missing ../../data/xmlschema.rng. Not sure why this happened, but if you get a similar error, you can download it from here and place it into the data folder right under your PEAR directory.

This XMI can later be used with Enterprise Architect, ArgoUML and other XMI tools.

Lectureship answered 28/9, 2012 at 13:57 Comment(3)
Would be great to add short instruction how to visualise class graph in eg. Enterprise Architect. 1) Import xmi to EA with: Ctrl+Alt+I or Menu > Package > Import/Export > Import Package From XMI File. 2) Show diagram: ???Immoderate
@VladimirVukanac First link in this answer (named "here").Tophet
It was a long time ago. I have to remember what was the goal. But thanks!Immoderate
D
1

(Edit : This answer is an alternative for people that want to generate UML class diagram from a PHP project, it doesn't explains how to read XMI files)

Goal

I need to see a graphical representation of the class relationships, possibly in varying depths and varying degrees of complexity. Also, it would be nice if the classes in the diagram are clickable. I do not necessarily need to generate documentation.

If your goal was to generate a class diagram from a PHP project, I found a better solution than use PHP_UML. What you probably want is BoUML, with this software, you can select a PHP project folder and reverse engineering it. Then create a class diagram. When you drag&drop the class on it, the relations are there unlike AlgoUML (If I'm not wrong). XMI files are no longer useful in this case.

Dorser answered 7/6, 2017 at 2:31 Comment(1)
It's shame but BoUML is outdated, e.g. it doesn't support mixed return types (function Foo: ?Bar) which breaks reversing. PHP_UML generates proper XMI but BoUML breaks during import for the same reason.Tophet

© 2022 - 2024 — McMap. All rights reserved.