Codeigniter is a PHP framework based on MVC(Modal-View-Controller) design pattern. MVC design pattern separate the data and business logic (modal) from the presentation(view).
In MVC , M stands for Modal which deals with all the database operations(CURD) such as insert, read, update and delete. And V stands for View, which is responsible for presentation or front-end layout/template. And C stands for Controller, it mediates between Modal and View.
Codeigniter 3 already comes with MVC pattern, we don’t need to do any special setup or configuration to write our codes in this pattern. But today i’ll show you more manageable way to writing a code. No doubt this pattern is enough to write your beautiful and manageable program, may be most of the Codeigniter lover doing the same but believe me after learned HMVC you’ll always follow this pattern and it’s very easy to setup.
HMVC stands for Hierarchical-Modal-View-Controller. As we already talk about MVC so what is this H in HMVC? H in HMVC is Hierarchical, it’s mean in codeigniter 3 we can write/manage our code in hierarchy format. We can do like this- we can create different-different folder for different purpose such as login, dashboard, users, report, notification etc. under these folder we’ll write our MVC codes by creating Modal-View-Controller folders. and the best part of HMVC is we can use these folders for our different projects.so each folder contains there separate and independent value.
How to setup HMVC in Codeigniter 3?
First of all thanks to ‘Wiredesignz’, who developed this HMVC package. You can get this package from here .
Just doanload & upload these files to your existing Codeigniter 3 application directory and it’s ready to write a code in modular format.
You have to create modules folder under application folder. Under modules folder you should create your desired module folder such as users, so basically folder structure for your module will be –
-application
-modules
-users
-controllers
-Users.php
-models
-UserModal.php
-views
-login.php
And all controller should extends MX_Controller
<?php
class Users extends MX_Controller
{
function __construct(){
parent::__construct();
}
public function index(){
}
}
Download “Codeigniter 3 HMVC – Starter Template”
codeigniter_3_hmvc.zip – Downloaded 700 times – 17.49 KB