SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 31

Thread: Php 5 + Uml

  1. #1
    SitePoint Zealot sike's Avatar
    Join Date
    Oct 2002
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Php 5 + Uml

    while playing around with the new object model of php 5 i discovered the
    mighty reflection api. to explore its complete power i decided to write
    a simple XMI generator (XMI is used by most UML tools for im/exporting diagrams).
    i must admit i am impressed : i took me only 3-4 hours to get the
    export stuff working. at the moment it only exports classes and interfaces but it is imho a very handy tool for getting an uml view on projects (see attachment). anyone interested in completing such a tool?

    Sike
    Attached Images Attached Images

  2. #2
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, but way above my current skills Never really got a hold of UML.

    The problem being for me at the moment is I see it as being wasteful of my time as I have no real need to use it just now

    But be interesting to see how things develop though

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Interesting, very interesting. I don't know about completing it, but I would defenently like to see the code. This could be a good tool to get a quick overview of a class library. Played with a similar tool last year on a large app in C# and it was defenently a good help.

  4. #4
    SitePoint Zealot
    Join Date
    Feb 2003
    Location
    Virginia
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Brilliant! I was just viewing WACT's documentation and even saw a request for someone to transform the current model into UML, and thought if it could be done automated.

    Brilliant! Took the words ..err.. diagram right out of my mind. Are you going to try and start a project for an automated XMI/UML tool?

    PS: Here is the specification for XMI for all those wondering. http://www.omg.org/technology/documents/formal/xmi.htm

  5. #5
    SitePoint Zealot
    Join Date
    Feb 2003
    Location
    Virginia
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another interesting find: http://www.phpedit.net/products/xmi2php/

  6. #6
    SitePoint Zealot sike's Avatar
    Join Date
    Oct 2002
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just cleaned some things up and zipped all files.
    you will need php5 and mysql4 to run the scripts and
    poseidonCE or any other xmi 2.0 capable editor to import
    the xmi and create diagrams from it.

    edit parse_source.php and generate_xmi.php for database settings.
    parse_source : will persist all classes to mysql with REPLACE
    generate_xmi : transforms persisted data into xmi v2.0 files : xmi.xmi and xmi.xml

    Sike

    ps. i am not shure if this really is xmi2 but poseidon claimed it (;
    Attached Files Attached Files

  7. #7
    SitePoint Zealot sike's Avatar
    Join Date
    Oct 2002
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Resolution
    yep. but as far as i remember i had problems with its ugly output

    Sike

  8. #8
    SitePoint Zealot
    Join Date
    Feb 2003
    Location
    Virginia
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you sike.

    I got the classes functioning and an XMI file was output but there was no class data for poseidon.

    Can you rewrite the direcitons less compact, mabey I missed a step because my datbase is not populated with ANY data!?

    Ok. Interesting project, look forward to seeing how it works.

    PS: Take a look at the XMI and XML file I get as output
    Attached Files Attached Files

  9. #9
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Played with it, had to fix the class names for the reflection classes though: ReflectionClass instead of Reflection_Class ( latest CVS ), other than that it worked like a charm.
    Attatched is a quick test with some of the cowiki classes through poseidon.
    Attached Files Attached Files

  10. #10
    SitePoint Zealot sike's Avatar
    Join Date
    Oct 2002
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh well looks like they changed all reflection classes names...
    i'll try rc2 and fix all code necessary tomorrow

    Sike

  11. #11
    SitePoint Zealot
    Join Date
    Feb 2003
    Location
    Virginia
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I tryed it and got it to work.. AWESOME!

    I decided to get ambitious as do something like say WACT. I used one of the example called BLOCK.php with the program sike has so generously offered and then used posiden to depict the image. You wact guys might get happy about this picture.

    It shows a compile in progress, so HTMLSax's classes are also loaded and diagrammed. This is goiing to be tool of the year. Awesome!

    PS: The Zip is a posiden CLASS UML file of the whole scenario.. So you only need posiden to view it - if you don;t have php5 and the program set up! Check it out.
    Attached Files Attached Files

  12. #12
    SitePoint Zealot sike's Avatar
    Join Date
    Oct 2002
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehe nice picture resolution. can't see that much but it shows
    the tool does its job

    i am currently adjusting stuff to rc2 and impementing properties to show up in the diagrams..

    Sike

  13. #13
    SitePoint Zealot sike's Avatar
    Join Date
    Oct 2002
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sike
    i am currently adjusting stuff to rc2 and impementing properties to show up in the diagrams..
    ok here is the new zip. cleaned some things up a bit and added properties.

    Sike
    Attached Files Attached Files

  14. #14
    SitePoint Zealot sike's Avatar
    Join Date
    Oct 2002
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    while working with the uml view on my project i realized that
    using packages would improve readability so i implemented it
    this will work only if you use DocBlocks with @package tags.
    same for variable types (@param).

    Sike
    Attached Files Attached Files

  15. #15
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice, will look at it tonight.
    One thing: how about implementing a couple of const when generating the xmi:
    PHP Code:
     XMIWriter::CLI 1;
     
    XMIWriter::BROWSER 2// default
     
    $xmi->setEnvXMIWriter::CLI ); 
    I use tools likt this in the terminal, and getting lots of html tags there doesn't do much good.
    Maybe a function:
    PHP Code:
     private function status$msg )
     {
          if( 
    $this->isCli() )
          {
               echo 
    $msg "\n";
          }
          else
          {
                echo 
    $msg "<br />";
          }
     } 
    then use that function to print the message depending on where you are executing the file. ( I'll implement this later tonight when I get off work if you don't want to do it )

  16. #16
    SitePoint Zealot sike's Avatar
    Join Date
    Oct 2002
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nucleuz
    Nice, will look at it tonight.
    One thing: how about implementing a couple of const when generating the xmi:
    PHP Code:
      XMIWriter::CLI 1;
      
    XMIWriter::BROWSER 2// default
      
    $xmi->setEnvXMIWriter::CLI ); 
    I use tools likt this in the terminal, and getting lots of html tags there doesn't do much good.
    Maybe a function:
    PHP Code:
      private function status$msg )
      {
           if( 
    $this->isCli() )
           {
                echo 
    $msg "\n";
           }
           else
           {
                 echo 
    $msg "<br />";
           }
      } 
    then use that function to print the message depending on where you are executing the file. ( I'll implement this later tonight when I get off work if you don't want to do it )
    good point. never used cli but i will try to implement this feature

    Sike

  17. #17
    SitePoint Zealot sike's Avatar
    Join Date
    Oct 2002
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    easy enough... i just used follwing code (stolen from an older thread) for checking if we run in cli mode :
    PHP Code:
    $this->cli = (php_sapi_name() == 'cli') ? true false
    Sike
    Attached Files Attached Files

  18. #18
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Another php2xmi

    Sike, I've just been using your php2xmi script and it works really well, great! Have you been developing it any further since your last post?

    I've just come across this which may be of interest to people
    http://tech.motion-twin.com/php_php2xmi.html

  19. #19
    SitePoint Guru Galo's Avatar
    Join Date
    May 2005
    Location
    Holland!
    Posts
    852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that's just sick, nice work ....
    Business as usual is off the menu folks, ...

  20. #20
    SitePoint Member
    Join Date
    May 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nice work

  21. #21
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    FYI php2xmi now works with Poseidon UML. Checkout from the repository to get the latest.

  22. #22
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    FYI php2xmi now works with Poseidon UML. Checkout from the repository to get the latest.
    Which is the URL of the repository?

  23. #23
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gregboulay
    Which is the URL of the repository?
    https://svn.motion-twin.com/php2xmi/trunk/src/php2xmi

  24. #24
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just wondering how do you run the program?....so totally clueless to the max, seriously have no idea...please do help.

  25. #25
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From the commandline. Open a shell and type php php2xmi --ouput=foo.xmi foo.php. (Assuming you have php.exe on the PATH variable and are standing in the dir where php2xmi is located). This will produce an xmi file, that you can open in poseidon UML.
    Note that it doesn't generate the classdiagram - only the entities. So you have to create a classdiagram from within poseidon, and then add the entities to the diagram.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •