简体   繁体   English

在Zend Framework 1.12中,Controller,Action的区分大小写的规则是什么

[英]In Zend Framework 1.12, what's the case sensitive rules for Controller,Action

I'm using the Zend Framework 1.12 in a project. 我在一个项目中使用Zend Framework 1.12。

Something is so weird. 有点奇怪。 I haven't use the Module. 我没有使用该模块。 Just the Controller and Action. 只是控制器和行动。

My Controller file name is MyCCController.php , 'CC' is upper case. 我的Controller文件名是MyCCController.php ,'CC'是大写的。

My action in this controller file is MyAAAction ,'AA' is upper case. 我在这个控制器文件中的动作是MyAAAction ,'AA'是大写的。

I tried the url http://localhost:8003/Mycc/myAA . 我尝试了网址http://localhost:8003/Mycc/myAA It shows the error-'Page not found'. 它显示错误 - '找不到页面'。 I googled and see some one said action name must be lower case. 我用Google搜索并看到有人说行动名称必须是小写。 So I change the 'MyAAAction' to 'myaaAction'. 所以我将'MyAAAction'改为'myaaAction'。 And the .phtml file is sitll 'views\\scripts\\MyCC\\MyAA.phtml'. .phtml文件是sitll'viewes \\ scripts \\ MyCC \\ MyAA.phtml'。 It doesn't care about the uppercase or lowercase. 它不关心大写或小写。

Then I visited the url http://localhost:8003/MyCC/myaa , It still shows 'Page not found'. 然后我访问了网址http://localhost:8003/MyCC/myaa ,它仍显示“找不到页面”。

I changed the url http://localhost:8003/Mycc/myaa , 'CC' became 'cc'.Then It's OK. 我更改了网址http://localhost:8003/Mycc/myaa ,'CC'变为'cc'。然后就可以了。

So my question is that is there any article elaborating the MVC URL case sensitive rules? 所以我的问题是,是否有任何文章详细阐述了MVC URL区分大小写的规则?

Or who can give me the rule about the name of controller,action,*.phtml file or something relative. 或者谁可以给我关于控制器,动作,* .phtml文件或某些相对的名称的规则。

And if I need the action Name as camelCase, how to realize it? 如果我需要动作名称为camelCase,如何实现呢?

Actually if you had read the Zend Framework 1.12 manual (at the end of page there is a "Case Naming Conventions" section) you can find this: 实际上,如果您已阅读Zend Framework 1.12手册 (在页面末尾有一个“案例命名约定”部分),您可以找到:

If you wish to have your controller class or action method name have multiple MixedCasedWords or camelCasedWords, you will need to separate those words on the url with either a '-' or '.' 如果您希望控制器类或操作方法名称具有多个MixedCasedWords或camelCasedWords,则需要将URL上的这些单词与“ - ”或“。”分开。 (though you can configure the character used). (尽管您可以配置使用的字符)。

So this is correct url call for your controller and action: http://localhost:8003/my-cc/my-aa 所以这是你的控制器和动作的正确url调用: http://localhost:8003/my-cc/my-aa

Also, when using (auto rendering) view scripts for that action it should be located and named as this /views/scripts/my-cc/my-aa.phtml 此外,当为该操作使用(自动渲染)视图脚本时,它应该被定位并命名为/views/scripts/my-cc/my-aa.phtml

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

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