PHP code example of nguyenanhung / codeigniter-hmvc

1. Go to this page and download the library: Download nguyenanhung/codeigniter-hmvc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nguyenanhung / codeigniter-hmvc example snippets


     
class Xyz extends MX_Controller 
{
    $autoload = array(
        'helper'    => array('url', 'form'),
        'libraries' => array('email'),
    );
}


$config['modules_locations'] = array(
    APPPATH.'modules/' => '../modules/',
);

$this->load->module('module/controller');

$this->load->module('module');

 $this->controller->method();


guyenanhung\CodeIgniter\HMVC\BaseLoader;

class MY_Loader extends BaseLoader
{
}


guyenanhung\CodeIgniter\HMVC\BaseRouter;

class MY_Router extends BaseRouter
{
}

Modules::run();


class Xyz extends MX_Controller 
{
    function __construct()
    {
        parent::__construct();
    }
}


$route['module_name'] = 'controller_name';

$this->load->model('module/model');


/** module and controller names are different, you must  module and controller names are the same but the method is not 'index' **/
modules::run('module/method', $params, $...);

/** module and controller names are the same and the method is 'index' **/
modules::run('module', $params, $...);

/** Parameters are optional, You may pass any number of parameters. **/

$this->load->module();

Modules::load();

$this->load->library(‘validation’)->run();

$this->load->language('language_file');

$config = $this->load->config(‘config_file’);


/** application/libraries/MY_Form_validation **/ 
class MY_Form_validation extends CI_Form_validation 
{
    public $CI;
}


class Xyz extends MX_Controller 
{
    function __construct()
    {
        parent::__construct();

        $this->load->library('form_validation');
        $this->form_validation->CI =& $this;
    }
}

 echo Modules::run('module/controller/method', $param, $...);