Symfony命令控制台链使用--no-interaction

时间:2015-09-18 15:21:59

标签: symfony console command

我有几个自定义Symfony控制台命令,它们具有交互和执行方法。

我想从另一个命令中调用其中一个命令,但是在使用--no-interaction标志时遇到了问题。

$command        = $this->getApplication()->find('app:create-user');
$bufferedOutput = new BufferedOutput();
$userInput      = new ArrayInput(
    array(
        'username'         => "d.vader",
        'password'         => "iAmY0urF4ther",
        'email'            => "d.vader@executor.com",
        'firstName'        => "Darth",
        'lastName'         => "Vader",
        '--no-interaction' => true
    )
);
$returnCode = $command->run($userInput, $bufferedOutput);

尽管设置了所有必需的参数,但这样做会导致“参数不够”错误。有没有其他人试图以这种方式使用--no-interaction标志?

1 个答案:

答案 0 :(得分:2)

尝试:

$userInput      = new ArrayInput(
    array(
        'command'          => 'app:create-user' // add this line
        'username'         => "d.vader",
        'password'         => "iAmY0urF4ther",
        'email'            => "d.vader@executor.com",
        'firstName'        => "Darth",
        'lastName'         => "Vader",
        '--no-interaction' => true
    )
);