Tutorial on HMVC (Hierarchical Model View Controller) architecture for CI (CodeIgniter) framework
Changes made in the CI framework:
-
Copied MX folder to application/third_party
-
Copied MY_Loader.php and MY_Router.php to application/core
-
Modules folder created under the application folder along with models,views and controllers folder in the new module named band.
-
Route information added in appliction/config/routes.php
-
Created .htaccess file.
(Note if your project is under some folder in the server then change the RewriteBase of htaccess file to the same name of the folder. Currently it is RewriteBase /hmvctutorials. If the project is directly under the document root of the server then make it / )
Following step is optional for the HMVC. It doesn't have dependency on template.
We can use the existing CI template or use the template library (http://williamsconcepts.com/ci/codeigniter/libraries/template/)
-
Copied Template.php to applicaiton/library folder
-
Copied template.php to application/config folder (Note: This is the file where you define the regions for the template)
-
Loaded the template library in application/config/autoload.php
Furthermore I have configured base_url in application/config/config.php, created assets folder for theme management and added layout and includes folder in the views folder.
That's all. You can just download or clone the project and put it under your server and run in the browser.
Sanjeev Subedi
