2014-10-30 148 views
2

我正在尝试编写运行其他几个命令的symfony2命令。 但是当我运行Symfony2命令运行缓存:clear -e prod

$this->getApplication()->find('cache:clear')->run(new ArrayInput(array(
    'command' => 'cache:clear', 
    '-e' => 'prod' 
)), $output); 
$output->writeln('Done clearing cache prod!'); 

它,它忽略了 '-e'=> '刺' 参数,并提供:中

Clearing the cache for the dev environment with debug true 

代替:

Clearing the cache for the prod environment with debug false 

回答

0

尝试,因为你卸下'command' => 'cache:clear',已经在你从应用程序中找到的那个Command上运行,所以你不需要再指定它。

$this->getApplication()->find('cache:clear')->run(new ArrayInput(array(
    '-e' => 'prod' 
)), $output); 
+0

它抛出:[RuntimeException]没有足够的参数。 – 2014-10-30 14:25:49

+0

@sepikas_antanas嗯,这很奇怪,我需要更多地了解这一点。我希望它能像[CommandTester](http://symfony.com/doc/current/cookbook/console/console_command.html#testing-commands)一样工作。另一种方法可能是使用Symfony Process来执行命令。 – 2014-10-30 14:37:27