根据教程上的说法,最好将文件命名为:
控制器首字母大写开头加全小写字母加Controller
动作(Action)以全小写字母加Action
至于为什么,当然是为了方便啊。其实是为了干净的URL
但是如果想以更加有代表性的命名,如:MyAnswerController下的getMyAnswerAction应该怎么写呢?
呵。下面有两个例子,自己看一下吧。如果这样写,那么url地址访问的时候就只能采取驼峰式的访问了。
访问地址:http://zend.localhost/index/base-index
目录结构:E:\www\zend\application\views\scripts\index\base-index.phtml
- <?php
- class IndexController extends Zend_Controller_Action
- {
- function indexAction()
- {
- }
- function baseIndexAction()
- {
- $this ->render();
- }
- }
访问地址:http://zend.localhost/foo-bar/base-index
目录结构:E:\www\zend\application\views\scripts\foo-bar\base-index.phtml
- <?php
- class FooBarController extends Zend_Controller_Action
- {
- function baseIndexAction()
- {
- $this ->render();
- }
- }