Last active
December 31, 2021 10:23
-
-
Save akrez/16b9fe0bd1c01245d99749cafa668c9d to your computer and use it in GitHub Desktop.
yii2: run migrate by web interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace app\controllers; | |
| use Yii; | |
| use yii\console\controllers\MigrateController; | |
| class ConsoleController extends Controller | |
| { | |
| public function actionMigrate() | |
| { | |
| if (!defined('STDIN')) define('STDIN', fopen('php://stdin', 'rb')); | |
| if (!defined('STDOUT')) define('STDOUT', fopen('php://stdout', 'wb')); | |
| if (!defined('STDERR')) define('STDERR', fopen('php://stderr', 'wb')); | |
| $consoleController = new MigrateController(Yii::$app->controller->id, Yii::$app); | |
| $consoleController->interactive = false; | |
| $consoleController->runAction('up'); | |
| $response = ob_get_clean(); | |
| $response = str_replace(">", "<br> >", $response); | |
| die($response); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment