【发布时间】:2014-03-20 13:55:56
【问题描述】:
我想从我的控制器执行命令 fos:elastica:populate。
我尝试了该代码,但它不起作用,我得到 error = 1 the var_dump show ""
$command = 'fos:elastica:populate';
$app = new Application($this->get('kernel'));
$app->setAutoExit(false);
$input = new StringInput($command);
$output = new ConsoleOutput;
$error = $app->run($input, $output);
var_dump($error);
var_dump(stream_get_contents($output->getStream());
有什么想法吗?
我尝试不同的代码.....
$command = $this->get('FosElasticaPopulateService');
$input = new StringInput('');
$output = new ConsoleOutput();
ladybug_dump($input);
// Run the command
$retval = $command->run($input, $output);
if(!$retval)
{
echo "Command executed successfully!\n";
}
else
{
echo "Command was not successful.\n";
}
var_dump(stream_get_contents($output->getStream()));
它说: '“无交互”选项不存在。' 在 输入->getOption('无交互') 在填充命令中。
如果我将代码更改为:
$input = new StringInput('--no-interaction');
它说:
'“--no-interaction”选项不存在。'
在
'ArgvInput ->addLongOption('无交互',null)'
【问题讨论】:
标签: php symfony foselasticabundle