1

I'm working on a Zend Framework API and need to follow a particular format for URLs, so I was hoping for some help regarding how to configure the routing correctly.

http://example.com/module/controller/method/actionNameHere

The above URL would need to route to the function actionNameHereAction.

Any help is appreciated.

4
  • Isn't that how ZF rolls, straight out the box? You just need to set your folder structure correctly and name your files and classes correctly? Commented Jul 14, 2011 at 7:45
  • @Leirith: Well, not exactly. He's got a that /method/ segment in there, not sure what purpose that serves. Looks like custom routes. But, you're right, it's pretty much a standard case, right out of the manual. Commented Jul 14, 2011 at 7:56
  • And what that part method stands for? Commented Jul 14, 2011 at 10:41
  • method is a static part of the URL, it will be in every request. actionNameHere should be camelCase. Commented Jul 14, 2011 at 23:06

2 Answers 2

1

The beauty of routing is that it gives you the tools for hiding exactly those pieces of information you are putting into your URL.

Apart from that, as far as I know ZF routes by default so that your URL would end up in ...

  • the action with name method of
  • the controller with name controller of
  • the module with name module

So either your example-URL is complicating things or you are almost there.

B/c actionNameHere would be a paramter you could handle in your action with name "methodAction".

But I think you want your URL to look like:

example.com/module/controller/actionNameHere

Sign up to request clarification or add additional context in comments.

Comments

1

In order to produce the URLs needed, I ended up creating a custom Dispatcher, as it wasn't in the routing that URLs were being converted from actionNameHere to actionnamehereAction, but in the dispatcher. I extended the standard dispatcher and overrode this behaviour so that the action name in the URL remained case-sensitive.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.