|codeIgniter HMVC is based on the Model-View-Controller development pattern. MVC is a software approach that separates application logic from presentation. In practice, it permits your web pages to contain minimal scripting since the presentation is separate from the PHP scripting.|
Let’s start to implement Codeigniter HMVC Framework.1. First and for most, lets download the latest stable version of codeigniter 3.x from codeigniter website. 2. Download the Modular Extensions here: HMVC Pattern <a href="https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc">Download</a> ( https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc )
Let's go Step By Step1. Extract Modular extension folder. You will find two folder there, the most important files is the core and third_party/MX folder. 2. Copy the Core Folder Files and Paste Inside Codeigniter Folder from application/core/. Core Folder contains MY_Loader.php and MY_Router.php files. 3. Copy Third Party/MX folder and Paste Inside Codeigniter Folder from application/third_party. 4. All of the main modular extensions that we need for our codeigniter HMVC 3.x is setup. Now, we need to test whether it is working or not. So, Go to your Codeigniter folder and Create “modules” folder inside Application 5. Using the folder “modules”, you can create different modules inside. Note: Make sure when we run the codeigniter 3.x in local server without implements HMVC. It display welcome message. 6. Now, Let's first check the welcome message in our local server with implements HMVC. 7. Create Folder “Welcome” inside “Modules”. Also create Controller and View Folders insides Welcome Folder. 8. Copy Welcome.php from Application/Controller to modules/welcome/controller/ . 9. Also Copy welcome_message.php from Application/view to moduels/welcome/view. 10. Check default controller is set in config/routes.php or not. If not set then set default controller to 'welcome' as below:
$route['default_controller'] = 'welcome';
</pre>Finally, you can check in your local server. It will display you welcome message as same it is shown without using HMVC.
CONCLUSIONSo now we already know how to implement HMVC Pattern in our Codeigniter 3.x Framework. You can now start creating your own cms or system using that pattern.
Tags: codeIgniter, codeIgniter HMVC, hmvc, MVC
This work is licensed under a
Creative Commons Attribution-