[英]Where are the routes for Gii defined in Yii framework?
我在webroot中创建了一个Yii应用程序。 我启用了Gii模块并修改了.htaccess,以删除网址中的index.php部分。
我还在config / main.php配置文件中定义了urlManager
组件。
'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>'
)
)
在浏览器中输入http://www.mydomain.com/gii
时,我将重定向到http://www.mydomain.com/gii/default/login
。
显然, urlManager
没有匹配的url rules
。 这是否意味着当Yii找不到任何匹配的url规则时,它将开始寻找匹配的模块?
bobo,是的,Yii确实开始寻找匹配的模块:
yii/framework/gii/GiiModule.php, Line 43
* http://localhost/path/to/index.php?r=gii
*
* If your application is using path-format URLs with some customized URL rules, you may need to add
* the following URLs in your application configuration in order to access GiiModule:
* <pre>
* 'components'=>array(
* 'urlManager'=>array(
* 'urlFormat'=>'path',
* 'rules'=>array(
* 'gii'=>'gii',
* 'gii/<controller:\w+>'=>'gii/<controller>',
* 'gii/<controller:\w+>/<action:\w+>'=>'gii/<controller>/<action>',
* ...other rules...
* ),
* )
* )
* </pre>
看起来它从正常规则开始,然后继续尝试其他模块(及其控制器/操作)。 似乎将模块ID(在本例中为Gii)用作全部的第一部分。
在进一步的研究中,是的。 有关更多信息,请参见Yii模块页面 。
你是什么意思?? Gii是一个模块,URL正确,您将使用默认值,因为CWebModule中的defaultController属性是'default',您可以扩展Gii并根据需要对其进行自定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.