I think the problem is path. Anyway you should consider not using Process
to call Symfony Commands. Console components is allowing to call commands e.g. in controller.
Example from docs:
// src/Controller/SpoolController.php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
class SpoolController extends Controller
{
public function sendSpoolAction($messages = 10, KernelInterface $kernel)
{
$application = new Application($kernel);
$application->setAutoExit(false);
$input = new ArrayInput(array(
'command' => 'swiftmailer:spool:send',
// (optional) define the value of command arguments
'fooArgument' => 'barValue',
// (optional) pass options to the command
'--message-limit' => $messages,
));
// You can use NullOutput() if you don't need the output
$output = new BufferedOutput();
$application->run($input, $output);
// return the output, don't use if you used NullOutput()
$content = $output->fetch();
// return new Response(""), if you used NullOutput()
return new Response($content);
}
}
Using this way you're sure that code will always work. When PHP is in safe mode (exec
etc. are turned off) Process
component is useless. Additionally you don't need to care about paths and other things otherwise the situation you're call command 'manually'.
You can read more about calling commands from controller here.