gii not working in yii

2019-02-12 22:04发布

I am new in yii framework. In my site gii shows the error

Error 403 You are not allowed to access this page.

I set the gii in the config file like this

'gii'=>array(
    'class'=>'system.gii.GiiModule',
    'password'=>'test123',
    'ipFilters'=>array('192.168.0.101','127.0.0.1','::1'),
),

still it show the error

标签: php yii gii
11条回答
劫难
2楼-- · 2019-02-12 22:46

Why do I get a 403 error when trying to use Gii?

If the above link does not help any, try to lookout appplication.log file in runtime folder to see what is going wrong.

查看更多
啃猪蹄的小仙女
3楼-- · 2019-02-12 22:46

Consider where your development server is located (same maching, LAN, WAN) and how your IP address changes towards the server.

  1. If your server is running on the same machine as does your client (the browser), you request the page from the localhost itself, thus your IP address is 127.0.0.1 and the default settings work.

  2. If your server is on a different machine but in your local area network (LAN), your IP address would typically look something like this 192.168.1.20 for the server. You can find it and adjust the code.

  3. If your server is across the web (WAN), then you would either have a

    • static IP address (if you are lucky)
    • or a dynamic IP address within a fixed range,
    • or worse, a more or less unpredictable dynamic IP address.

Only if the very last (unpredictable dynamic IP address) is the case, I would follow this answer by schmunk who also points out the risk.

Using $_SERVER['REMOTE_ADDR'] seems unnecessary to me.

查看更多
我想做一个坏孩纸
4楼-- · 2019-02-12 22:50
if (YII_ENV_DEV) {

    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];
}

After replace it by using this default code,

and user this url.

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

查看更多
爷、活的狠高调
5楼-- · 2019-02-12 22:52

I had a very similar problem. For me it was that my user account didn't have writeaccess to my PHP session_save_path folder. When I browsed to it in Windows 7, it told me I needed permission and it would grant it if I chose OK. I did. Everything was fixed.

查看更多
仙女界的扛把子
6楼-- · 2019-02-12 22:54

try this

    'gii' => array(
        'class' => 'system.gii.GiiModule',
        'password' => 'pasword',
        'ipFilters'=> false,
        'generatorPaths' => array(
            'bootstrap.gii'
        ),
    ),
查看更多
登录 后发表回答