문제는 경로라고 생각합니다. 어쨌든 Process
을 사용하지 말고 Symfony 명령을 호출해야합니다. 콘솔 구성 요소는 명령을 호출 할 수 있습니다. 컨트롤러에서. 문서에서
예 :
// 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);
}
}
당신이 그 코드가 항상 작동 확신이 방법을 사용. PHP가 안전 모드 (exec
등이 꺼져있는 경우)이면 Process
구성 요소는 쓸모가 없습니다. 또한 경로 및 기타 사항에 대해 신경 쓰지 않아도됩니다. 그렇지 않으면 상황을 '수동으로'명령이라고 부릅니다.
컨트롤러 here에서 명령을 호출하는 방법에 대해 자세히 읽을 수 있습니다.
"작동하지 않는다"는 것은 무엇을 의미합니까? 오류 메시지가 있습니까? –