From a controller method, I want to run a Symfony command, in the background.
public function collaboratorsSendInvitationsAction($company_id)
{
$process = new Process(
'php ' . $this->get('kernel')->getRootDir() . '/console nd:company send-invitations --id ' . $company_id
);
$process->start();
return $this->redirectToRoute('collaborators_list', [
'company_id' => $company_id,
]);
}
The process seems to work because if I execute $process->getPid();
I get a pid, but the command is not executed.
I have investigated, made several tests, and I arrive at the following result:
When I comment line 290 of the class Process.php ($this->status = self::STATUS_STARTED;
) then the command is executed. If no, nothing happens.
Has anyone ever come across this problem? What can cause this? I specify that I use Symfony 2.8.28, and PHP 7.1.10. The problem is found on MacOS and Ubuntu Server.
When I dump the process and execute the manually displayed command, everything works.