Overriding module configuration in ZF2 – Rob Allen's DevNotes


: 7

Let's say that you install the ZF-Common's User module. By default, it sets up its routes under the /user path segment like this:


This config section will create the routes /user and through the magic of child_routes, also create /user/login and other required routes.

If you don't want /user and would prefer /member, then it's easy enough to change. Just add a new config file to the project's config/autoload folder:


As a result of using child_routes, all the other routes under this route will pick up the same segment, so /user/login is now accessed via /member/login. Also, as each route is named independently from its route, all the url view helper calls continue to work as the route's name continues to be zfcuser/login.

Obviously, this technique works for any other config setting that you may wish to override.