How to handle yii2 migrations on hosts without console access?(如何在没有控制台访问的主机上处理 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 的东西,但是在尝试运行时遇到 
permissione deniedyii migrate --interactive=0 
我也试过这个:添加一个 actionMigrateUp 到 frontend/controllers/siteController.php
I tried also this: added an actionMigrateUp to frontend/controllers/siteController.php
public function actionMigrateUp()
{
    // https://github.com/yiisoft/yii2/issues/1764#issuecomment-42436905
    $oldApp = Yii::$app;
    new yiiconsoleApplication([
        '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
异常 'yiiaseInvalidRouteException' 带有消息'无法解决请求:site/migrateUp' inC:xampphtdocswwwvendoryiisoftyii2aseController.php:122
exception 'yiiaseInvalidRouteException' with message 'Unable to resolve the request: site/migrateUp' in C:xampphtdocswwwvendoryiisoftyii2aseController.php:122
推荐答案
您创建的操作无法使用
The action that you have created is not accesible with
/frontend/web/index.php?r=site/migrateUp
但有
/frontend/web/index.php?r=site/migrate-up
否则一切都会好起来的.
Otherwise everything should be fine.
这篇关于如何在没有控制台访问的主机上处理 yii2 迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在没有控制台访问的主机上处理 yii2 迁移?
				
        
 
            
        基础教程推荐
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
 - php中的foreach复选框POST 2021-01-01
 - 将变量从树枝传递给 js 2022-01-01
 - php 7.4 在写入变量中的 Twig 问题 2022-01-01
 - PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
 - php中的PDF导出 2022-01-01
 - Web 服务器如何处理请求? 2021-01-01
 - 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
 - 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
 - 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
				
				
				
				