简体   繁体   English

Yii框架中定义Gii的路线在哪里?

[英]Where are the routes for Gii defined in Yii framework?

I created a Yii application in the webroot. 我在webroot中创建了一个Yii应用程序。 I enabled the Gii module and modify the .htaccess to remove the index.php part in the url. 我启用了Gii模块并修改了.htaccess,以删除网址中的index.php部分。

I also have the urlManager component defined in the config/main.php configuration file. 我还在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>'
        )
)

When I enter http://www.mydomain.com/gii in the browser, I get redirected to http://www.mydomain.com/gii/default/login . 在浏览器中输入http://www.mydomain.com/gii时,我将重定向到http://www.mydomain.com/gii/default/login

Obviously, there is no matching url rules in the urlManager . 显然, urlManager没有匹配的url rules Does this mean that when Yii cannot find any matching url rule, it will then start looking for a matching module? 这是否意味着当Yii找不到任何匹配的url规则时,它将开始寻找匹配的模块?

bobo, yes, it does look like Yii starts looking through matching modules: 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>

Looks like it starts with the normal rules and then moves on down to trying additional modules (and their controller/actions) after that. 看起来它从正常规则开始,然后继续尝试其他模块(及其控制器/操作)。 Seems to be using the module ID (gii in this case) as the first part of it all. 似乎将模块ID(在本例中为Gii)用作全部的第一部分。

On further research, yes, that's the case. 在进一步的研究中,是的。 See the Yii Module page for more info. 有关更多信息,请参见Yii模块页面

What you mean?? 你是什​​么意思?? Gii is a module and the URL is right you have the default because the defaultController proprerty in CWebModule is 'default' you can extend Gii and customize it if you want. Gii是一个模块,URL正确,您将使用默认值,因为CWebModule中的defaultController属性是'default',您可以扩展Gii并根据需要对其进行自定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM