I’ve been reading about modules for codeigniter for quite a while and have decided to dive into it. I’ve gotten the basic concept, each module is a seperate “MVC”, hence ease in maintaining, adding, etc, but need a little help understanding proper implementation.
Firstly, specifically I’d like an explanataion for the line in original modular extension hmvc site
“To use Modular Separation only, without HMVC, controllers will extend the CodeIgniter Controller class.”
what excatly does this mean? if someone could explain it’s meaning and purpose it would be really helpful.
Also, a little more conceptual explanation of HMVC, modular extension and seperation etc would be great. Like how to decide when to extend modules, seperate them, and what excatly this means.
All this means is that if you want your controller to be able to take advantage of
Modules::run(), which can be called from anywhere in your app (including other modules), you need to have that controller extend the MX_Controller class like so:MX_Controlleris the base controller for the Modular Extensions package. You can also choose to extend any other controller that itself extendsMX_Controller, like so:If you don’t need this functionality (you probably don’t), then you don’t need to do anything differently in your module’s controllers:
“Modules” in this context are just mini CI applications, each with it’s own models, views, controllers, etc. It helps keep your code organized and gives you more ability to separate unrelated components. Theoretically, any CI application can become a module and vice-versa.