getting Gii to work on Yii 2.0 getting Gii to work on Yii 2.0 php php

getting Gii to work on Yii 2.0


This is how to get Gii working from a remote server for an advanced setup template.

In the frontend config file. For example:

/frontend/config/main-local.php

Add the following code:

if (!YII_ENV_TEST) {    // configuration adjustments for 'dev' environment    $config['bootstrap'][] = 'debug';    $config['modules']['debug'] = 'yii\debug\Module';    $config['bootstrap'][] = 'gii';    $config['modules']['gii']=[      'class' =>  'yii\gii\Module',      'allowedIPs' => ['*'],    ];}

The interesting part is the Gii array which has been modified.


Step 1: Add Following line to required-dev of composer.json

"yiisoft/yii2-gii": "*"

Step 2: Update your composer.Step 3: Add Following line to your frontend/config/main.php file. Don't incude these ..........

  'modules' => [    ............    'gii' => [      'class' => 'yii\gii\Module', //adding gii module      'allowedIPs' => ['127.0.0.1', '::1']  //allowing ip's     ],    ...........  ]

Step 4:If you have enabled your clean url then go to

project_name/frontend/web/gii

if not then go to

project_name/frontend/web/index.php?r=gii

You can follow the link yii2_gii


Like described in the Docs you have to adjust the allowed IPs in the /frontend/config/main-local.php:

    if (!YII_ENV_TEST) {      ...      $config['bootstrap'][] = 'gii';      $config['modules']['gii'] = [        'class' => 'yii\gii\Module',        'allowedIPs' => ['127.0.0.1', '::1', '192.168.*.*']      ];    }

If you have modified your /frontend/config/main.php like this for pretty URLs:

    return [    ...    'components' => [      ...      'urlManager' => [            'class' => 'yii\web\UrlManager',            'enablePrettyUrl' => true,            'showScriptName' => false      ],      ...    ];

You can call gii with the URL

    yourVM.local/gii

(Having yourVM.local point to your Frontend Module in your Hosts file.)