简体   繁体   中英

Run console command from another one

How do I run a console controller action from another console controller action?

I've tried the following

class FooController extends Controller
{
    public function actionBar()
    {
        $this->run('baz/quux', ['baz'=>'quux']);
    }
}

class BazController extends Controller
{
    public function actionQuux($baz)
    {
        // ...
    }
}

I'm getting an error

Error: Unknown option: --baz

Though the quux action of the baz controller has the baz parameter and running ./yii baz/quux quux succeeds.

I don't mean to specify an option, I don't even use options. I want to specify the action's parameter. What should be the format of the parameters array?

事实证明,参数数组不应包含参数键......它应该如下所示

$this->run('baz/quux', ['quux']);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM