How to Properly Make use of Codeigniter's HMVC
- by Branden Stilgar Sueper
I have been having problems wrapping my brain around how to properly utilize the modular extension for Codeigniter. From what I understand, modules should be entirely independent of one another so I can work on one module and not have to worry about what module my teammate is working on. I am building a frontend and a backend to my site, and am having confusion about how I should structure my applications.
The first part of my question is should I use the app root controllers to run modules, or should users go directly to the modules by urls?
IE: in my welcome.php
public function index()
{
$this->data['blog'] = Modules::run( 'blog' );
$this->data['main'] = Modules::run( 'random_image' );
$this->load->view('v_template', $this->data);
}
public function calendar()
{
$this->data['blog'] = Modules::run( 'blog' );
$this->data['main'] = Modules::run( 'calendar' );
$this->load->view('v_template', $this->data);
}
My second part of the question is should I create separate front/back end module folders
-config
-controllers
welcome.php
-admin
admin.php
-core
-helpers
-hooks
-language
-libraries
-models
-modules-back
-dashboard
-logged_in
-login
-register
-upload_images
-delete_images
-modules-front
-blog
-calendar
-random_image
-search
-views
v_template.php
-admin
av_template.php
Any help would be greatly appreciated.