2014-10-30 27 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