私は問題が経路だと思います。とにかく、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からのコマンドの呼び出しについて詳しく読むことができます。
「動作しません」とはどういう意味ですか?エラーメッセージはありますか? –