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

how do you use multiple controllers with a micro collection?

I'm using micro collections as modules in a large application and I'm trying to figure out how to define multiple handlers in a collection. If I call setHandler multiple times on the last call is used when finding routes. When I look at https://docs.phalcon.io/en/latest/api/Phalcon_Mvc_Micro_Collection.html.

I notice that it has a method getHandlers that returns all the handlers registered in this collection, but I can't see how to register multiple handlers. I want to do this because my application uses one type of controller for the rest api call and a different api call for my views.

edited Aug '14

I dont think you have an option to set multiple handlers. An easy solution would be to register them as a seperate collection with a namespace in front like /v1, or to a different sub domain like api. I would also recommend that you seperate your API into a seperate project but it sounds like you are wanting to just keep everything together.

Check this repo for some ideas: https://github.com/cmoore4/phalcon-rest/blob/develop/routes/collections/example.php