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

route handler from another handler definition

Dear all, I have a short design question : within a micro application using basic routes and anonymous function handler, is there a way to "call" one route from the anonymous function body of another route ? For example, I would like to use to use the result of $app->get("/routeA/",[...]) in the definition of $app->get("/routeB/",[...]) (edited)

problem being : I'm not sure what to look for in the documentation ...

The question is why you want to do it? Just move code which you want run in both routes to service.

edited Oct '17

Seems like you want Dispatcher, which is N/A in Micro. Like @Jurigag said, use services for a common logic.

Route handlers are meant to handle routes, directly. Then in your controller hierarchy you can build common logic in base controller etc.

Thanks for your answers. As suggested, I have extracted buisness logic out of the handlers. I'll try next to construct proper services out of that code. I guess the relevant part of the documentation is https://docs.phalcon.io/hu/3.2/di/ ?

Then in your controller hierarchy you can build common logic in base controller etc.

ChildHandler extends Base