Advanced Gii 提示 403

本文介绍了如何在Yii框架中正确配置Gii组件及其使用条件。通过修改main-local.php文件来激活Gii,并在config.php中设置允许访问Gii的IP地址。此配置对于开发者调试和生成代码非常有用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值