Question

I've been struggling with this problem the last 2 hours. I'm trying to add a regex-route to my Zend Framework (V1) application. My other routes are static and stored in my application.ini file and that is where i want to put some new regex-routes.

Before i continue to work on more complex regex routes i started to translate the following (working) route to a regex route:

resources.router.routes.shift-display.route = /shift/display/:id
resources.router.routes.shift-display.defaults.module = shift
resources.router.routes.shift-display.defaults.controller = index
resources.router.routes.shift-display.defaults.action = display

Here is what i came up with:

resources.router.routes.shift-display.type = "Zend_Controller_Router_Route_Regex"
resources.router.routes.shift-display.regex = "shift/display/(\d+)"
resources.router.routes.shift-display.defaults.module = shift
resources.router.routes.shift-display.defaults.controller = index
resources.router.routes.shift-display.defaults.action = display
resources.router.routes.shift-display.map.1 = id
resources.router.routes.shift-display.reverse = "shift/display/%d"

But it's not working. It seems the route isn't recognized by the router. When trying to open e.g. vh.localhost/shift/display/7 i get "Invalid controller specified (display)" so the router uses the default route. I also tried to prepend the regex-route with a slash. I tried to use the url-helper to generate links (with passed ID param) using the new regex-route and it works.

Anyone has a clue?

Was it helpful?

Solution

Sometimes is it just that simple. When definining the route, the mistake was made in that line:

resources.router.routes.shift-display.regex = "shift/display/(\d+)"

It has to be

resources.router.routes.shift-display.route = "shift/display/(\d+)"

4 hours for nothing. But at least I finally found it ;-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top