1

I am attempting to call a console command from a controller using the Process component in Symfony2 to have it run in the background, however all it does is hang and end up at a white screen. This is an example of what fails:

$process = new Process('php app/console list');
$process->setWorkingDirectory($this->get('kernel')->getRootDir().'/../');
$process->run();
print $process->getOutput();

I have tried interchanging $process->run() with $process->start() and it still doesn't work.

ComputerWolf
  • 1,201
  • 2
  • 10
  • 14

1 Answers1

0

Checkout AsyncServiceCallBundle, it allows you to execute your application service's methods in background without having to wait until they are finished. Just use it like this:

$this->get('krlove.async')->call('service_id', 'method', [$arg1, $arg2, $arg3]);

It uses this approach to make such calls asynchronous.

Andrii Mishchenko
  • 2,626
  • 21
  • 19