【问题标题】:Yii 2.0 enabling remote access to giiYii 2.0 启用对 gii 的远程访问
【发布时间】:2014-12-05 09:23:34
【问题描述】:

简单的问题,尝试在 yii 2 中启用对 gii 的远程访问 - 文档说 http://www.yiiframework.com/doc-2.0/guide-start-gii.html

Note: If you are accessing Gii from a machine other than localhost, the access will be denied by default for security purpose. You can configure Gii to add the allowed IP addresses as follows,

'gii' => [
    'class' => 'yii\gii\Module',
    'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] // adjust this to your needs
],

问题是,它没有说明在哪里添加 - 猜测 config/web.php

但是在哪个部分呢?

【问题讨论】:

    标签: yii2


    【解决方案1】:

    2个地方你需要添加这个。

    通常在你的 main-local.php 中是这样完成的

    if (!YII_ENV_TEST) {
        $config['bootstrap'][] = 'gii';
        $config['modules']['gii'] = [
            'class' => 'yii\gii\Module',
        ];   
    }
    

    因此,您需要在配置的引导部分和模块部分中添加 gii。这将基本上将它们从您的 config/main.php 附加到数组中 返回 [ 'id' => '应用后端', 'basePath' => 目录名(DIR), 'controllerNamespace' => '后端\控制器', '引导' => ['日志'], '模块' => [ ], ],

    在您提供的链接上,请查看上方。你应该这样做:

    if (YII_ENV_DEV) {
        $config['bootstrap'][] = 'gii';
        $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] // adjust this to your needs
    ];
    }
    

    【讨论】:

    • 我有这个在 config/web.php if (YII_ENV_DEV) { // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = 'yii\debug\Module'; $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = 'yii\gii\Module'; }
    • 谢谢 - 让我很困惑原来没有 class => .. 有效
    猜你喜欢
    • 1970-01-01
    • 2012-03-31
    • 1970-01-01
    • 2016-03-28
    • 1970-01-01
    • 2016-02-15
    • 1970-01-01
    • 1970-01-01
    • 2015-02-03
    相关资源
    最近更新 更多