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

Phalcon HMVC application with cross modules sub request functionality

Hi Dears, Recently there was a lot of discussions about the HMVC Pattern support in Phalcon and the ability to build multiple modules applications that support cross modules sub request during the main request.

Today I want to show you the HMVC application I built that supports all the above, it uses separate dependency injector container for each requested module as we don't need the same configuration for every module, all you have to do to request another module is this:

<?php

$result = $this->di->getShared('app')->module(
      'module_name',
      'controller_name',
      'action_name',
      array('param1' => 'param1_value')
 );

Please review it at this link https://github.com/hishamaborob/Phalcon-HMVC-Multi-Modules and give me your feedback.

Yes dschissler thank you for your question, actually I have faced many situation where I needed to to reuse the results of specific module, here is some of them:

  1. If you have ecommerce website and want to reuse the (customers reviews box view) in many location like (product details page and seller page ..) just request the reviews module and send the product id in the parameters.
  2. And if you have news website and need to also reuse the (fast news bar) in many modules pages.

dschissler I liked your project and in the same time I think my approach is very useful and can achieve any goals and benefits forward like SOA, DRY code, easy caching on module level and easy to make nested HTTP caching, I deal with you that it needs more enhancement like shared view layout, and it also need better configuration on the module level.