YII相关知识点记录

1.YII脚本名称在url重的显示与否

YII的入口文件是index.php,很多时候为了url的美观设置其不现实又或者显示,这在YII的配置文件中石油相关的配置的。

在components中添加如下数组:

 

'urlManager'=>array(
'showScriptName'=>false,
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),

 之后通过YII::app->getHomeUrl()便可隐藏index.php。其实我在这里是有一点疑问的,YII::app()->getBaseUrl()对这个参数的配置不感冒。

网上找了一个链接解释了一下这个问题,算是看明白了一些。

http://www.yiiframework.com/forum/index.php/topic/18416-showscriptnamefalse-not-working/

 

2.YII中modules的设置

YII可以通过gii脚手架工具添加module,添加方法为为点击Module Generator,输入modules名称,系统会自动生成一系列文件。之后在protected/config/main.php文件中增加如下配置文件

 

'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'password',
'generatorPaths'=>array(
             'application.gii',   // a path alias
            ),
//If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
'aminly',
),

访问的url的地址为:http://localhost:8080/lottery/index.php/aminly/default/index
 

相关参考资料:http://blog.csdn.net/mengxiangbaidu/article/details/7041296

 

 

3.yii中通过自动crud的action模块是加入权限的,在ajax或URL中直接访问会分别报403错误和bool(false)错误。 

转载于:https://www.cnblogs.com/php321/p/3348542.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值