【问题标题】:Gii doesn't load in custom build of Yii2Gii 没有加载到 Yii2 的自定义构建中
【发布时间】:2017-07-28 18:06:32
【问题描述】:

我正在使用 Yii2 的 Foundationize 自定义版本,它已经有几年的历史了,但总的来说似乎运行得很好。

但是,当我开始运行 gii 工具以生成新模型等时,路由被忽略,我的应用程序的索引页面只是重新加载。

我尝试访问的 URL 是 http://localhost/web/index.php?r=gii

我的 index.php 中有这一行

defined('YII_ENV') or define('YII_ENV', 'dev');

我的 config/web.php 包含以下内容

if (YII_ENV_DEV) {
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
    'class' => 'yii\gii\Module',
    'allowedIPs' => [$_SERVER['REMOTE_ADDR']], // always allow on current server
];}

我在某处错过了一步吗?我尝试了来自 Yii 主站点的“基本”设置,这似乎在同一台服务器上运行良好。提前致谢。

【问题讨论】:

    标签: php yii2 gii


    【解决方案1】:

    由于某种原因,这次安装中的路由被破坏了

    而不是

    http://localhost/web/index.php?r=gii

    我用过

    http://locahost/web/index.php/gii

    一切都很好

    【讨论】:

    • 原因是你使用了漂亮的 url。 :)
    【解决方案2】:

    我认为您修改了配置(在 config/web.php 中)

    'components' => [
           'urlManager' => [
              'class' => 'yii\web\UrlManager', //clase UrlManager
              'showScriptName' => true,  // to remove index.php
              'enablePrettyUrl' => true  //for Friendly url
            ],
     ],
    

    【讨论】:

      【解决方案3】:
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多