我需要在服务中运行命令
app/console fos:elastica:populate --no-reset --index=profile --type=team
终端所有工作正常,但我需要在服务中运行
$application = new \Symfony\Bundle\FrameworkBundle\Console\Application($this->kernel);
$application->setAutoExit(false);
//Upload in Elastic
$options = array('command' => 'fos:elastica:populate', "--no-reset" => true, "--index=profile" => true, "--type=team" => true);
$upload = $application->run(new \Symfony\Component\Console\Input\ArrayInput($options));
有错误:
[InvalidArgumentException]
The "--index=profile" option does not exist.
答案 0 :(得分:0)
另一种选择可能是使用// .../Service/YourService.php
use Symfony\Component\Process\Process;
class YourService
{
/.../
public function launchPopulateCommand()
{
$process = new Process('php app/console fos:elastica:populate --no-reset --index=profile --type=team');
$process->run();
}
/.../
}
组件来启动特定命令:
{{1}}
答案 1 :(得分:0)
我解决了
$options = array('command' => 'fos:elastica:populate', "--no-reset" => true, "--index" => 'profile', "--type" => 'team');
$upload = $application->run(new \Symfony\Component\Console\Input\ArrayInput($options));