Friday, 15 June 2012

symfony2 - Running more than one console commands in a controller Symfony 2 -



symfony2 - Running more than one console commands in a controller Symfony 2 -

first of give thanks looking @ question. here's question.

i want run 3 existing console commands in symfony 2 controller. wrote 3 separate functions (see below). managed run 'doctrine:mapping:import' (find code below) without issue within controller. next thing wanted generate entities based on imported mapping files. not run 'doctrine:generate:entities' command without shutting downwards , booting kernel (which think bad idea, @ code below). without shutting downwards , booting kernel won't generate entities me. after shutting downwards , booting kernel creates entities me (i happy now). next problem having when run 'doctrine:generate:form' command (find code below). when run code after generating entities say's 'class 'the name of class' not exist'. can't happen. because running form build command after generating entities. seek searching class whether there accessing file physically. , there. totally stuck in here, i'd say.

well, know it's lengthy question. if can tell what's causing generate entities not create entities without shutting downwards , booting kernal , form builder command not work, entity files there, really appreciated. 1 thing noticed though, commands (3 functions) works fine when run 1 @ time. want phone call these 3 functions 1 after another. problem occurred when sequentially phone call these 3 functions.

code 'doctrine:mapping:import'

public function executeimportcommandaction($filter) { $kernel = $this->container->get('kernel'); $app = new application($kernel); $app->setautoexit(false); $input = new \symfony\component\console\input\arrayinput( array('command' => 'doctrine:mapping:import', 'bundle' => 'testclientbundle', '--filter' => $filter, 'mapping-type' => 'yml')); $app->dorun($input, new \symfony\component\console\output\consoleoutput()); }

code 'doctrine:generate:entities'

public function executebuildformcommandactions($entity) { $kernel = $this->container->get('kernel'); $kernel->shutdown(); $kernel->boot(); $app = new application($kernel); $app->setautoexit(false); $input = new \symfony\component\console\input\arrayinput( array('command' => 'doctrine:generate:entities', 'name' => 'testclientbundle', '--no-backup' => 'true')); $app->dorun($input, new \symfony\component\console\output\consoleoutput()); }

code 'doctrine:generate:form'

public function executebuildformcommandactions($entity) { #$kernel = $this->container->get('kernel'); $app = new application($kernel); $app->setautoexit(false); $input = new \symfony\component\console\input\arrayinput( array('command' => 'doctrine:generate:form', 'entity' => 'testvclientbundle:'.$entity.'')); $app->dorun($input, new \symfony\component\console\output\consoleoutput()); }

thanks lot in advance. cheers!

do know there process component? http://symfony.com/doc/current/components/process.html

you can run symfony command it.

symfony2 symfony-2.3 symfony2.4

No comments:

Post a Comment