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 for beginner

Hi! I just want to ask if there's an updated tutorial on how to use phalcon with hmvc structure. (please don't redirect me to vokuro). Thank you.



13.8k
edited May '17

If you use phalcon tools then you can create a basis structure but there are also project skeletons on github, see:

I hope this will help you a bit.

Thanks for your response, but im looking for HMVC tutorial.

I dont know about any tutorial, nor do i think there will be/is necessary. HMVC is a development pattern/doctrine, independent of Phalcon.

Here's a crude example: https://github.com/phalcon/mvc/tree/master/hmvc

That's all you need to know in order to create a project conforming with HMVC

People should first know whenever they actually need some design pattern or not.

@lajosbencz : Instead of vote up button, I've clicked vote down on your post by accident. Cannot change it. :/



9.7k

One of the good HMVC examples is the Drupal module system where an add-on module can be an almost standalone application. In Drupal 7, a large module, like the ecommerce module, can have it's own add-on modules to create a three level hierarchy.

Some Drupal themes are HMVC in that they provide administration pages to let the site administrator configure the theme. The theme becomes a subsystem instead of just a view decorator.

My current project uses Volt in a subsystem containing template creation and editing for special purpose templates. You could do the same with a generic email send subsystem attached to multiple actions across different controllers.



9.7k

I read the HMVC example on github. How do you use it?

The code appears to create application as a service. Do you create multiple applications or reuse the service in some way?

As an example, suppose you have a shop with a separate stock system. You want available stock displayed in the shop pages using the stock application mixed in with the shop application. If you create two applications in $di, they share the same config, db, and every other service. Would you move some of the services from $di into the applications?