Config Gii


I am newbie in Yii2 and I downloaded the basic template and i configured the database. I realized that GII is configured in web.php

if (YII_ENV_DEV) { 

     $config['preload'][] = 'debug'; 

     $config['modules']['debug'] = 'yii\debug\Module'; 

     $config['modules']['gii'] = 'yii\gii\Module'; 


But when i tried to access in index.php?r=gii i get the error 403 Forbidden.

I checked the index.php and YII_ENV_DEV is defined like dev

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

Somebody know what i missing?


i comment out the line $config[‘modules’][‘gii’] = ‘yii\gii\Module’;

and add new following line into the web.php

[indent] ‘modules’ => [

            'gii'=> [

                'class' => 'yii\gii\Module',

                'allowedIPs' => [''],


I’ve adjusted the guide to reflect this difference:


My problems was the ‘allowedIPs’. I was added the following lines

'allowedIPs' => ['', '::1', 'localhost']

And my app is hosted in a server so I have to add allowed IPs of my current computer.

I solved with:

'allowedIPs' => ['']

Why do you want Gii on server btw.?

Because we are a team developing the app and we have the test version in a hosting. We have a git repository and upload the files by FTP to see the changes. Thus we use a single database and not have to maintain many databases updated.

It is our solution, maybe there is a better way.

Sure there is. Check how you can deploy via git and use DB migrations to keep DB structure in repository.

I wonder how to set the rule for gii when we use urlmanager?


It should work as is.