Run a Symfony Command asynchronously

I tried to run the following :

$process = new Process(['php', 'bin/console', 'app:run-batch', $batch->getId()],
            $this->getParameter('kernel.project_dir'));
$process->start();

But the process doesn’t run at all. Then if I add this line to wait for the process to end :

$process->wait();

It works, but the thing is that I specifically put my code in a command to be able to run it asynchronously. Anybody can help me on this ? Would be greatly appreciated !

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *