gii 404 Not Found and 403 Forbidden

If you are getting a 404 not found error when trying to access gii, you probably don’t have gii set up in your config. This may happen if you initialize your advanced template in prod environment instead of dev.

To activate Gii, modify your web/index.php file as follows:

Change: defined(‘YII_ENV’) or define(‘YII_ENV’, ‘prod’);
To: defined(‘YII_ENV’) or define(‘YII_ENV’, ‘dev’);

Add the following:

  1. if (YII_ENV_DEV) {
  2.     $config['bootstrap'][] = 'gii';
  3.     $config['modules']['gii'] = [
  4.         'class' => 'yii\gii\Module',
  5.         'allowedIPs' => ['XXX.XX.XX.XX']
  6.     ];
  7. }

Replace XXX.XX.XX.XX with the IP address you are accessing the gii module from.
whatismyip.com

Published by

Joel Bowers

Web developer since 1999. PHP, YII2, Laravel, Javascript, HTML, CSS, jQuery, Perl, Wordpress, MySQL.

Leave a Reply

Your email address will not be published. Required fields are marked *