How to run console command in yii2 from web
问题 I have created a console command in console/controllers with SuggestionController . If i run command like php yii suggestions , its working. I want to know how to execute console command from web without any extensions of yii2 . 回答1: It can be done much simpler $oldApp = \Yii::$app; new \yii\console\Application([ 'id' => 'Command runner', 'basePath' => '@app', 'components' => [ 'db' => $oldApp->db, ], ); \Yii::$app->runAction('migrate/up', ['migrationPath' => '@yii/rbac/migrations/',