如何在没有控制台访问权限的主机上处理yii2迁移? [英] How to handle yii2 migrations on hosts without console access?

查看:78
本文介绍了如何在没有控制台访问权限的主机上处理yii2迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功在共享主机上创建并上传了高级模板.

I've succesfully created and uploaded advanced template on my shared host.

下一步,我必须运行yii migrate.

As next step, I must run the yii migrate.

但是我不能,因为我没有控制台访问权限.

But I cannot because I've not the console access.

您能向我建议什么?

请注意

  • 我不能更改主机,因为这不是我的决定
  • 我无法使用SSH访问服务器
  • 我已经尝试过类似PHPShell的方法,但尝试运行yii migrate --interactive=0时却得到了permissione denied
  • I cannot change the host, because it's not a decision of mine
  • I cannot access the server using SSH
  • I've already tried something like PHPShell, but I got permissione denied when trying to runyii migrate --interactive=0

我也尝试过:在frontend/controllers/siteController.php

public function actionMigrateUp()
{
    // https://github.com/yiisoft/yii2/issues/1764#issuecomment-42436905
    $oldApp = \Yii::$app;
    new \yii\console\Application([
        'id'            => 'Command runner',
        'basePath'      => '@app',
        'components'    => [
            'db' => $oldApp->db,
        ],
    ]);
    \Yii::$app->runAction('migrate/up', ['migrationPath' => '@console/migrations/', 'interactive' => false]);
    \Yii::$app = $oldApp;
}

但是当我访问/frontend/web/index.php?r=site/migrateUp时,我得到了404

But when I visit /frontend/web/index.php?r=site/migrateUp I got a 404

异常"yii \ base \ InvalidRouteException",并显示消息无法执行 解决请求:site/migrateUp' C:\ xampp \ htdocs \ www \ vendor \ yiisoft \ yii2 \ base \ Controller.php:122

exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request: site/migrateUp' in C:\xampp\htdocs\www\vendor\yiisoft\yii2\base\Controller.php:122

推荐答案

您创建的操作不适用于

/frontend/web/index.php?r=site/migrateUp

但使用

/frontend/web/index.php?r=site/migrate-up

否则一切都应该没事.

这篇关于如何在没有控制台访问权限的主机上处理yii2迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆