Skip to content

Instantly share code, notes, and snippets.

@akrez
Last active December 31, 2021 10:23
Show Gist options
  • Select an option

  • Save akrez/16b9fe0bd1c01245d99749cafa668c9d to your computer and use it in GitHub Desktop.

Select an option

Save akrez/16b9fe0bd1c01245d99749cafa668c9d to your computer and use it in GitHub Desktop.
yii2: run migrate by web interface
<?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