views:

133

answers:

3

The Zend standard for action names is camelCase, yet if I create an action with camel casing, the request fails because it tries to call the method (action) without the camel casing!

Example:

I have an action named "changeEmail" in module "abc". The method is "changeEmailAction" (created by Zend Tool). If I try to access /abc/changeEmail, I get an error returned that says 'Message: Action "changeemail" does not exist and was not trapped in __call()'.

The ONLY way I have been able to make it work is by only creating action names in all lowercase. This makes for terrible readability and is contrary to the suggested naming convention. What am I missing?

A: 

I found the answer to this:

In the url, for multi-word action names, you must separate the words with hyphens, i.e.

/abc/change-email

will call the method "changeEmailAction" in the controller.

MikeH
+1  A: 

You should use hyphen-seperated names in your URLs, e.g. /abc/change-email.

aib
+2  A: 

The default behavior of a Zend Framework Action Controller/Router is to enforce a URL naming scheme of all lowercase, with dashes separating the words.

http://example.com/controller/my-thing

When this URL is translated into an action name, camel casing is applied.

public function myThingAction()
{
}

If you really really really want URLs that are camel cased, you should look into configuring your application with a custom Zend Router

Alan Storm
Thanks. I figured this out a couple hours after posting, but your explanation will be helpful for anyone else that didn't quite "get it" at first.
MikeH