0

I'm trying to switch to ZF2 from ZF1. From what I've read about the new Zend\MVC\Router and the way it is configured, it looks like every single location should be described in ['router']['routes'] config key.

Is that really so? In ZF1 you could build a complex app with multiple locations and not have a single route described. I find it hard to believe, hopefully I am missing something.

Thanks!

temuri
  • 2,767
  • 5
  • 41
  • 63

1 Answers1

1

The routing works in a similar way to ZF1. The config in the skeleton app includes a few example routes, one of which is a /:controller/:action route (line 42). So this is your out-of-the-box ZF1 style MVC route.

In ZF1, the framework adds a /:controller/:action and /:module/:controller/:action route for you (which you had to remove if you had some custom requirements). In ZF2 you have to define the routes yourself, but if you want the same setup as ZF1, the skeleton app setup works in the same way, just without the module prefix.

Tim Fountain
  • 33,093
  • 5
  • 41
  • 69
  • I think you are wrong about it. I've dissected https://github.com/akrabat/zf-web.git and - yes, indeed, there is a route for every single location that I checked. Look at [Controller Config](https://github.com/akrabat/zf-web/blob/master/config/autoload/page-controller.global.php). Why would author of ZF2 site configure every single location if it weren't required? – temuri Jul 14 '13 at 18:11
  • 2
    There are some advantages to verbose routing - it's a lot clearer what's going on, for one thing. The zf-web source takes advantage of ZF2's tree-style routing - there are a number of routes there that are children of the 'participate' route for example. That routing configuration could certainly be shortened, but there's no particular advantage in doing so. – Tim Fountain Jul 14 '13 at 19:09