【笔记】Yii2 - Gii使用:配置
2016-06-03 11:42
525 查看
Yii2提供的工具有6个:Model Generator, CRUD Generator,Controller Generator,Form Generator,Module Generator,Extension Generator。如下图所示。
在浏览器地址输入:http://hostname/index.php?r=gii,即可看到下面的页面。
在yii项目的config文件夹中,配置Gii的相关信息内容如下:
配置YII_ENV_DEV为true,也就是开发环境的方式是在项目的入口文件中/web/index.php,可以看到开发环境的配置:
在config配置中,如果不添加allowedIPs的属性,系统默认的是['127.0.0.1', '::1‘],表示Gii只能在本地环境使用。
yii\gii\Module
在浏览器地址输入:http://hostname/index.php?r=gii,即可看到下面的页面。
在yii项目的config文件夹中,配置Gii的相关信息内容如下:
$config = [...]; if(YII_ENV_DEV) { // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = [ 'class' => 'yii\debug\Module', ]; $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', ]; } return $config;Gii的配置在YII_ENV_DEV的判断中,是以模块的方式使用。YII_ENV_DEV表示当前项目环境是开发状态下才能使用。
配置YII_ENV_DEV为true,也就是开发环境的方式是在项目的入口文件中/web/index.php,可以看到开发环境的配置:
// comment out the following two lines when deployed to production defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); $config = require(__DIR__ . '/../config/web.php'); (new yii\web\Application($config))->run();代码中,第一行为配置debug模式为true,也就是开启debug模式,第二行即为开启当前环境为开发环境。
在config配置中,如果不添加allowedIPs的属性,系统默认的是['127.0.0.1', '::1‘],表示Gii只能在本地环境使用。
yii\gii\Module
class Module extends \yii\base\Module implements BootstrapInterface { /** * @inheritdoc */ public $controllerNamespace = 'yii\gii\controllers'; /** * @var array the list of IPs that are allowed to access this module. * Each array element represents a single IP filter which can be either an IP address * or an address with wildcard (e.g. 192.168.0.*) to represent a network segment. * The default value is `['127.0.0.1', '::1']`, which means the module can only be accessed * by localhost. */ public $allowedIPs = ['127.0.0.1', '::1'];如果在远程使用,则要配置相关可访问IP,如下所示:
$config['modules']['gii'] = [ 'class' => 'yii\gii\Module', 'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*'], ];
相关文章推荐
- php整数判断
- php的DES加密算法
- WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL作用
- php 计算字符串长度
- 升级到php7相关问题,日请求过亿QQ会员活动平台PHP7升级实践
- thinkphp查询一周内的新闻排行10条
- php 利用转转法去除重复数组
- php file_put_contents时出现Permission denied的警告
- matplotlib核心剖析
- PHP的self::与static::,new self()和new static()之分
- PHP 多线程、多进程
- PHP 环境变量
- PHP中余数、取余的妙用
- PHP与MySQL结合—出错问题总结
- 每天laravel-20160821|CookieJar-1
- 每天laravel-20160821|CookieJar-1
- Yii2 如何使用事件
- (转载)Laravel学习笔记(一)安装配置开发环境
- js 与 php 时间戳的区别(毫秒与秒的计算方式)
- PHP常用函数封装