【问题标题】:Symfony2 command run cache:clear -e prodSymfony2 命令运行缓存:clear -e prod
【发布时间】:2014-10-30 12:50:05
【问题描述】:

我正在尝试编写运行很少其他命令的 symfony2 命令。 但是当我运行时

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

它忽略 '-e' => 'prod' 参数给出:

Clearing the cache for the dev environment with debug true

代替:

Clearing the cache for the prod environment with debug false

【问题讨论】:

    标签: symfony command


    【解决方案1】:

    尝试删除'command' => 'cache:clear',,因为您已经在运行从应用程序中找到的命令,因此您无需再次指定它。

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

    【讨论】:

    • 它抛出:[RuntimeException] 没有足够的参数。
    • @sepikas_antanas 嗯,这很奇怪,我需要进一步研究。我本来希望它的工作方式与CommandTester 一样。另一种可能是使用 Symfony Process 来执行命令。
    猜你喜欢
    • 2015-09-27
    • 2020-04-01
    • 2012-07-10
    • 2017-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多