| Model visualization with symfony [message #19660] |
Fri, 12 January 2007 21:15  |
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:
Attachment: schema.png
(Size: 12.46KB, Downloaded 1532 time(s))
|
|
|
|
|
|
| Re: Model visualization with symfony [message #25580 is a reply to message #19660 ] |
Thu, 12 April 2007 20:29   |
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:
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   |
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 #57391 is a reply to message #19660 ] |
Thu, 31 July 2008 11:24  |
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]
|
|
|