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

HMVC request cross modules

I have checked this HMVC example:

https://github.com/phalcon/mvc/tree/master/hmvc

It is good example on how to make HMVC request cross controller, but is it also possible to do the same in case of cross modules?

For example I'm in Module (A) - Controller (AC) - Action (ACN), and I need to make HMVC request to Module (B) - Controller (BC) - Action (BCN).

Is it possible using dispatcher? and should I register my modules first with their services and loaders?

Thank you



98.9k

Al mult-module application does not share a dispatcher so you can't make HMVC requests between modules. I think you can move the shared functionality to user components and make them available using a common autoloader.

All of these functionality is shared between modules: https://github.com/phalcon/biko/tree/master/library/Biko, because both of them are using the same autoloader: https://github.com/phalcon/biko/blob/master/config/loader.php#L7

edited Aug '14

Actually I'm not thinking of moving shared functionality, I need each module to be independent and encapsulates specific functionalities so it could be reusable and called (Module as standalone service).

I already have implemented the idea of same autoloader for all modules, but now I'm thinking about one of the following to make HMVC request between modules:

  • Inside a module I will try to get another registered application module, then using that module dispatcher I could dispatch the action and controller I want.
  • I will try to assign the same dispatcher for every modules.

Thank you for your information and help, I appreciate any other help in this discussion.

Hi Hisham, also I need the same thing. Did you maybe find some solution ? Thanks

Hi Vladimir, Yes I found a solution, it is in the final touches, I will publish it as soon as I finish and test it. Thank you for your interest