How can I call a console command in web application in Yii 2.0

后端 未结 5 921
余生分开走
余生分开走 2020-12-19 13:37

I have a console command to generate user report. I want to call the same from my web application. I am using Yii 2.0.0 beta version.I tried to follow answers given in this

5条回答
  •  清酒与你
    2020-12-19 14:07

    I think this is the simplest solution:

    $controller = new YourConsoleController(Yii::$app->controller->id, Yii::$app);
    $controller->actionYourConsoleAction();
    

提交回复
热议问题