1- 首先检查下/console/config/main-local.php是否有Gii组件
1 <?php
2 return [
3 'bootstrap' => ['gii'],
4 'modules' => [
5 'gii' => 'yii\gii\Module',
6 ],
7 ];
2- 在/host/frontend/config.php中加入允许ip组
1 <?php
2
3 $config = [
4 'components' => [
5 'request' => [
6 // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
7 'cookieValidationKey' => 'lFqOLA3QvRRj5hbwEfO9R4OJb49dveX0',
8 ],
9 ],
10 ];
11
12 if (!YII_ENV_TEST) {
13 // configuration adjustments for 'dev' environment
14 $config['bootstrap'][] = 'debug';
15 $config['modules']['debug'] = [
16 'class' => 'yii\debug\Module',
17 ];
18
19 $config['bootstrap'][] = 'gii';
20 $config['modules']['gii'] = [
21 'class' => 'yii\gii\Module',
22 'allowedIPs' => ['127.0.0.1','198.181.45.103','59.58.112.119'],
23 ];
24 }
25
26 return $config;
本文介绍了如何在Yii框架中正确配置Gii组件及其使用条件。通过修改main-local.php文件来激活Gii,并在config.php中设置允许访问Gii的IP地址。此配置对于开发者调试和生成代码非常有用。
4379

被折叠的 条评论
为什么被折叠?



