Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement HMVC in codeigniter 3.0?

Currently I'm using codeigniter version 3.0. I want to know how to implement HMVC structure in it, can anyone help?

like image 571
sitrarasu annadurai Avatar asked Jun 16 '15 11:06

sitrarasu annadurai


People also ask

WHAT is HMVC CodeIgniter 3?

HMVC stands for Hierarchical Model View Controller. Modular Extensions make the Codeigniter PHP framework modular. Modules are groups of independent components, typically model, controller and view, arranged in an application modules sub-directory that can be dropped into other Codeigniter applications.

Is CodeIgniter is HMVC?

CodeIgniter is loosely based and works on MVC (Model-View-Development) pattern. It can also use the Hierarchical Model View Controller (HMVC). Added as an extra benefit it helps your applications with lots of modular functions.

What is difference between MVC and HMVC?

The difference from a traditional MVC is that instead of displaying the comments in a fully separate page, they are displayed inline below the article the user is viewing. In this regard, HMVC strives to increase code modularity, aid reusability, and maintain a better separation of concerns.

How to make modules in CodeIgniter?

This works in v3 and allows you to create an application/modules/your_module folder and then access libraries and models by calling $this->load->add_package_path(APPPATH. 'modules/resources', FALSE); .


1 Answers

codeigniter 3 hmvc modules folder for:

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

1- Download files and copy C.i.3.0 forder in application

2- .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

3- create /application/modules

4- /application/modules/welcome create in controllers, models, views

5- Create /application/modules/welcome/controllers/Welcome.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends CI_Controller {

    public function index()
    {
        $this->load->view('welcome_message');
    }
}

enjoy :)

IMPORTANT : 'controllers' and 'models' initials files in the folder should be large. 'views' of files per folder in the letter should be small

enter image description here

like image 102
Limitless isa Avatar answered Oct 10 '22 08:10

Limitless isa