[英]How to handle yii2 migrations on hosts without console access?
I've succesfully created and uploaded advanced template on my shared host. 我已在我的共享主机上成功创建并上传了高级模板。
As next step, I must run the yii migrate
. 下一步,我必须运行yii migrate
。
But I cannot because I've not the console access. 但我不能,因为我没有控制台访问权限。
What could you suggest to me? 你能给我什么建议?
Please note that 请注意
permissione denied
when trying to run yii migrate --interactive=0
我已经尝试过类似PHPShell的东西,但在尝试运行yii migrate时,我被permissione denied
yii migrate --interactive=0
I tried also this: added an actionMigrateUp to frontend/controllers/siteController.php
我也试过这个:将actionMigrateUp添加到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;
}
But when I visit /frontend/web/index.php?r=site/migrateUp
I got a 404 但是当我访问/frontend/web/index.php?r=site/migrateUp
我得到了404
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 异常'yii \\ base \\ InvalidRouteException',消息'无法解析请求:site / migrateUp'在C:\\ xampp \\ htdocs \\ www \\ vendor \\ yiisoft \\ yii2 \\ base \\ Controller.php中:122
The action that you have created is not accesible with 您创建的操作无法访问
/frontend/web/index.php?r=site/migrateUp
but with 但随着
/frontend/web/index.php?r=site/migrate-up
Otherwise everything should be fine. 否则一切都会好的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.