config/web.php:
$config = [ ... ]; if (yii_env_dev) { $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = 'yii\gii\module'; }
在web/index.php中设置yii_env_dev:
defined('yii_env') or define('yii_env', 'dev');
如果是从非localhost访问需要在配置文件中作如下设置:
'gii' => [ 'class' => 'yii\gii\module', 'allowedips' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] // adjust this to your needs ],
测试:
http://hostname/index.php?r=gii
