0

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.

Ahmed-Anas
  • 5,471
  • 9
  • 50
  • 72

1 Answers1

2

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home

To use HMVC functionality, such as Modules::run(), controllers must extend the MX_Controller class.

To use Modular Separation only, without HMVC, controllers will extend the CodeIgniter Controller class.

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:

class Foobar extends MX_Controller {}

MX_Controller is the base controller for the Modular Extensions package. You can also choose to extend any other controller that itself extends MX_Controller, like so:

// Base controller
class Module_Controller extends MX_Controller {}

// Actual controller
class Blog extends Module_Controller {}

Modules::run() is designed for returning view partials

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:

class Foobar extends CI_Controller {}
class Foobar extends MY_Controller {} // etc.

"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.

Wesley Murch
  • 101,186
  • 37
  • 194
  • 228