We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Subrouter ?

I need a route in the format of /{version}/doSomething and I would like to

  • Load dependancies and
  • Select a namespace

based on the version parameter. Is it possble to create a router that just handles the /{version} route, handles the loading and selection, and then dispatches the remaining route to another router ?

You may be better off doing it within the controller, checking the version param, then forwarding or redirecting to a different route, same traffic logic but rerouting done within a controller instead, so the main {version} route takes in all related routes, then it sends people the right way.

I would recommend looking at Modules.