[英]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.