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