symfony
symfony forum
Home » support » General discussion » Model visualization with symfony
Model visualization with symfony [message #19660] Fri, 12 January 2007 21:15 Go to next message
roga  is currently offline roga
Messages: 55
Registered: December 2006
Member
Adding some simple lines enables propel's graphviz dot file generation:

in /data/symfony/tasks/sfPakePropel.php add:
pake_desc('create a graphviz dot file for current model');
pake_task('propel-graphviz', 'project_exists');


and

function run_propel_graphviz($task, $args)
{
  _propel_convert_yml_schema(false, 'generated-');
  _propel_copy_xml_schema_from_plugins('generated-');
  _call_phing($task, 'graphviz');
  $finder = pakeFinder::type('file')->name('generated-*schema.xml');
  pake_remove($finder, array('config', 'plugins'));
}


Now you can use it like that:

> symfony propel-graphviz
...
propel > graphviz:
     [echo] +------------------------------------------+
     [echo] |                                          |
     [echo] | Generating Graphiz for YOUR Propel       |
     [echo] | project!                                 |
     [echo] |                                          |
     [echo] +------------------------------------------+
...


This creates a folder "graph" in your projects folder containing a "schema.dot" file which can be converted to e.g. a PNG file using the graphviz package from http://www.graphviz.org/

Fonts, colors, shapes etc. can be customized.

I attached a sample:
index.php/fa/224/0/

  • Attachment: schema.png
    (Size: 12.46KB, Downloaded 1532 time(s))

Re: Model visualization with symfony [message #19680 is a reply to message #19660 ] Sat, 13 January 2007 17:55 Go to previous messageGo to next message
francois  is currently offline francois
Messages: 1636
Registered: October 2005
Faithful Member
Maybe you could make a plugin out of it ?
Re: Model visualization with symfony [message #19681 is a reply to message #19660 ] Sat, 13 January 2007 18:24 Go to previous messageGo to next message
COil  is currently offline COil
Messages: 466
Registered: September 2006
Faithful Member

That's nice. Razz


my Symfony Blog - http://www.strangebuzz.com
The symfony web debug bar as a standalone library : PEAR::PHP_Debug
Re: Model visualization with symfony [message #25326 is a reply to message #19660 ] Sun, 08 April 2007 16:11 Go to previous messageGo to next message
flarian  is currently offline flarian
Messages: 37
Registered: November 2006
Member
Wow, this is really great! Would it be possible to include this in symfony? It just creates a file - but having this file is an incredible bonus...
Re: Model visualization with symfony [message #25580 is a reply to message #19660 ] Thu, 12 April 2007 20:29 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
Terrific! After simply adding the following line, I got the schema map!!!

$ diff -wU 1 /usr/share/pear/data/symfony/tasks/sfPakePropel.php.org /usr/share/pear/data/symfony/tasks/sfPakePropel.php
--- /usr/share/pear/data/symfony/tasks/sfPakePropel.php.org     2007-02-22 09:49:14.000000000 -0500
+++ /usr/share/pear/data/symfony/tasks/sfPakePropel.php 2007-04-12 13:38:45.000000000 -0400
@@ -43,2 +43,5 @@
 
+pake_desc('create a graphviz dot file for current model');
+pake_task('propel-graphviz', 'project_exists');
+
 function run_propel_convert_yml_schema($task, $args)
@@ -383 +386,10 @@
 }
+
+function run_propel_graphviz($task, $args)
+{
+  _propel_convert_yml_schema(false, 'generated-');
+  _propel_copy_xml_schema_from_plugins('generated-');
+  _call_phing($task, 'graphviz');
+  $finder = pakeFinder::type('file')->name('generated-*schema.xml');
+  pake_remove($finder, array('config', 'plugins'));
+}


francois, why can't we put it directly in sfPakePropel.php, why a plugin instead?

I've submitted a patch, against trunk/data/tasks/sfPakePropel.php latest revision, 3525. Details at:
http://trac.symfony-project.com/trac/ticket/1659

check it out and get the patch there.

roga wrote on Fri, 12 January 2007 15:15

...a "schema.dot" file which can be converted to e.g. a PNG file using the graphviz package from http://www.graphviz.org/

Fonts, colors, shapes etc. can be customized....


roga, can you elaborate a bit more about them?

Having installed the graphviz package, it took me a while to figure out how to open the .dot file, because there isn't a tool called graphviz. Only after having tried each individual files did I know how to open it:

dotty graph/schema.dot &


Thanks


xpt


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: Model visualization with symfony [message #25584 is a reply to message #19660 ] Thu, 12 April 2007 20:52 Go to previous messageGo to next message
bladus  is currently offline bladus
Messages: 88
Registered: December 2005
Location: Germany
Member
I can just agree, having this as a pake task would be awesome!


Symfoniac Weblog
Re: Model visualization with symfony [message #25589 is a reply to message #19660 ] Thu, 12 April 2007 21:13 Go to previous messageGo to next message
roga  is currently offline roga
Messages: 55
Registered: December 2006
Member
I already submitted a patch some time ago, but it wasn't implemented until now. And I had no time for the plugin as well. It's on my todo-list.

@xpt:
I used a GUI (http://home.so-net.net.tw/oodtsen/wingraphviz/index.htm) but as far as I know the command is:
dot -Tpng input.dot -o output.png
Re: Model visualization with symfony [message #25594 is a reply to message #25589 ] Thu, 12 April 2007 21:48 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
Thanks, that works:

dot -Tpng graph/schema.dot -o graph/schema.png


What's cool about it is that it can handle all dabase tables from plugins as well. Here is an example from my

[Tutorial] My Second Project - Admin Generator
http://www.symfony-project.com/forum/index.php?t=msg&th= 5064&

index.php?t=getfile&id=282&private=0

  • Attachment: schema.png
    (Size: 25.64KB, Downloaded 1257 time(s))


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: Model visualization with symfony [message #35625 is a reply to message #19660 ] Fri, 14 September 2007 19:24 Go to previous messageGo to next message
KRavEN  is currently offline KRavEN
Messages: 213
Registered: May 2007
Faithful Member
I created a plugin out of this. No need to edit the symfony base files.

http://trac.symfony-project.com/trac/wiki/sfPropelGraphviz
Re: Model visualization with symfony [message #35633 is a reply to message #35625 ] Fri, 14 September 2007 21:24 Go to previous messageGo to next message
roga  is currently offline roga
Messages: 55
Registered: December 2006
Member
KRavEN wrote on Fri, 14 September 2007 19:24

I created a plugin out of this. No need to edit the symfony base files.

http://trac.symfony-project.com/trac/wiki/sfPropelGraphviz


Thank you very much! Smile
Re: Model visualization with symfony [message #35634 is a reply to message #19660 ] Fri, 14 September 2007 21:27 Go to previous messageGo to next message
KRavEN  is currently offline KRavEN
Messages: 213
Registered: May 2007
Faithful Member
No problem. It was super simple to do. Took longer to do the wiki stuff than it took to make the plugin.
Re: Model visualization with symfony [message #35644 is a reply to message #35634 ] Sat, 15 September 2007 03:19 Go to previous messageGo to next message
phuson  is currently offline phuson
Messages: 16
Registered: March 2007
Location: California
Junior Member

KRavEN,

I get this from running this in the command line,

symfony plugin-install http://plugins.symfony-project.com/sfPropelGraphviz


---

>> plugin installing plugin "http://plugi...y-project.com/sfPropelGraphviz"
>> pear Could not download from
>> pear "http://plugins.symfony-project.com/sfPropelGraphviz"
>> pear Invalid or missing remote package file
>> pear Package "http://plugins.symfony-project.com/sfPropelGraphviz"
>> pear is not valid

Any ideas?

Thanks!
Re: Model visualization with symfony [message #35645 is a reply to message #35644 ] Sat, 15 September 2007 03:27 Go to previous messageGo to next message
phuson  is currently offline phuson
Messages: 16
Registered: March 2007
Location: California
Junior Member

Nevermind. Smile

I just download the file directly and plugin-install it.

http://trac.symfony-project.com/trac/attachment/wiki/sfPrope lGraphviz/sfPropelGraphviz-0.1.0.tgz


It works great by the way. Smile

[Updated on: Sat, 15 September 2007 05:00]

Re: Model visualization with symfony [message #35779 is a reply to message #19660 ] Mon, 17 September 2007 13:07 Go to previous messageGo to next message
KRavEN  is currently offline KRavEN
Messages: 213
Registered: May 2007
Faithful Member
Yeah, I'm not sure when the files uploaded to the wiki go to the plugins.symfony.com site. I'm pretty sure I completed all the steps listed on the wiki site for hosting a plugin there.
Re: Model visualization with symfony [message #38875 is a reply to message #19660 ] Tue, 06 November 2007 16:11 Go to previous messageGo to next message
KRavEN  is currently offline KRavEN
Messages: 213
Registered: May 2007
Faithful Member
I fixed the svn problem a while back but forgot to post. Plugins have to end with plugin or they won't get hosted. I renamed it and it should work now.
Re: Model visualization with symfony [message #38979 is a reply to message #38875 ] Wed, 07 November 2007 17:26 Go to previous messageGo to next message
dmclark  is currently offline dmclark
Messages: 43
Registered: December 2005
Location: Boston, MA
Member

Fantastic plugin!

I am having trouble making it igenerate a new .dot file after I modfy schema.xml, even after clear-cache

Any ideas?
Re: Model visualization with symfony [message #57391 is a reply to message #19660 ] Thu, 31 July 2008 11:24 Go to previous message
sorac  is currently offline sorac
Messages: 17
Registered: September 2007
Junior Member
Hi,

For the symfony 1.1 users, here is the 1.1 version :

1/ Create a new task :

> symfony generate:task graphviz

2/ Edit the task file, and copy folowing lines into the execute function :

protected function execute($arguments = array(), $options = array()) {
$this->schemaToXML(self::CHECK_SCHEMA, 'generated-');
$this->copyXmlSchemaFromPlugins('generated-');
$this->callPhing('graphviz', self::CHECK_SCHEMA);
$this->getFilesystem()->remove(sfFinder::type('file')->name('generated-*schema.xml'));
}

3/ Change the Task class extend :

class graphvizTask extends sfPropelBaseTask {

4/ That's all, now you can generate graph of your schema.yml with :

> symfony graphviz

Enjoy !

[Updated on: Thu, 31 July 2008 12:00]

Previous Topic:Icons for file extensions
Next Topic:Bebo Applications
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software