YII框架学习 第二天(2) gii 和 模块
扫描二维码
随时随地手机看文章
1 gii 代码生成工具,类似于一些ide创建一个类,自动会生成 一些代码和一些文件
那么如何配置呢?
第一步:到main.php中配置一些啊,这是YII framework种的主配置文件
'modules'=>array( // uncomment the following to enable the Gii tool 'gii'=>array( 'class'=>'system.gii.GiiModule', 'password'=>'123456', // If removed, Gii defaults to localhost only. Edit carefully to taste. 'ipFilters'=>array('127.0.0.1','::1'), ) )
默认是全部注释到的
如何就可以http://localhost/你的项目名/index.php?r=gii
yii会自动识别r= 后面的是模板还是 控制器
在刚才去除注释的数组中,有一个password键名
之后会自动创建一些文件(红框中是默认的,其他的是我自己添加了)
怎么样 很熟悉吧,也是MVC模式,和第一天的规则一致
然后在main.php 中 的 'modules'中 加上 'background'
注意:在模块中,要访问的话需要在路由中加入模块名
localhost:/项目名称/index.php?r=background/manager/login
和昨天的访问方式还是不一样的