Slightly confused about the Zend Framework naming conventions in the coding standard

At the time of writing….

The documentation in the Zend Framework, that outlines theĀ  Zend_Controller Basics, states that:

The default dispatcher is Zend_Controller_Dispatcher_Standard. It defines controllers as CamelCasedClasses ending in the word Controller, and action methods as camelCasedMethods ending in the word Action: FooController::barAction(). In this case, the controller would be referred to as foo and the action as bar.

However, the Zend_Controller Quick Start guide states:

By default, it Title-cases the controller name and appends the word Controller. Thus, in our example above, the controller roadmap is mapped to the class RoadmapController.

…and…
Similarly, the action value is mapped to a method of the controller class. By default, the value is lower-cased, and the word Action is appended. Thus, in our example above, the action components becomes componentsAction, and the final method called is RoadmapController::componentsAction().

I’m a newbie to the whole Zend framework thing, but these elements of the documentation seem to be contradicting each other. I have already put followed the quick start instructions and managed, not only, to get my Hello World page, but also to get a test controller and action set up and working. So, if there is a discrepancy I will tend to side with the Quick Start naming convention.

Update

Actually, having read my own blog post I realise that I was making a fuss of nothing. Both naming conventions are different but they come together to make sense. By following the standard in the ‘Zend_Controller Quick Start’ guide, the standard in the ‘Zend_Controller Basics’ section becomes true.

However, I’m still left wondering what happens when a controller is made up of MoreThanOneWord - how does Zend know where to uppercase the second, third, fourth words etc?

Leave a Reply