Why are my camel actions in Zend MVC trying to call non-camelcased names?

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

Example:

I have an action called "changeEmail" in the "abc" module. This method is "changeEmailAction" (created by the Zend Tool). If I try to access / abc / changeEmail, I get an error message that says: "Message: The action" changeemail "does not exist and does not fall into __call ()."

The only way I was able to get it to work was to create action names only in lower case. This leads to terrible readability and contradicts the proposed naming convention. What am I missing?

+4
source share
3 answers

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

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

When this URL is converted to an action name, the camel shell is applied.

 public function myThingAction() { } 

If you really really want the URLs to be camels, you should study the configuration of your application with the Zend Router

+17
source

I found the answer to this question:

In the URL for verbose action names, you must separate hyphenated words, i.e.

/ a / change-mail

will call the "changeEmailAction" method in the controller.

+2
source

Your URLs should use hyphen names. /abc/change-email .

+1
source

Source: https://habr.com/ru/post/1316605/


All Articles