Where Is Consolecommandrunner In Yii 2.0?

Hi, folks,

I’m trying to wire up a db migration controlled by the app code for cases when getting a shell prompt on a remote server isn’t an option. In Yii 1.1 I found this link in the wiki…


…but I am not seeing ‘ConsoleCommandRunner’ anywhere. What is the ‘Yii 2.0’ preferred way of doing something link this?

Thanks much


Did you check the docs?

But of course. The migration doc seems to be focused entirely on manual migrations from the command line. I’m looking to run migrations via code (i.e. adding a ‘migrate’ button to an admin screen).

Not checked… but would something like this not work?

\yii\console\Controller::run($route, $params = []);

Here’s an example how to run multiple Gii commands. https://github.com/schmunk42/yii2-sakila-module/blob/master/commands/GiibatchController.php

Great - thanks!