Modular Extensions Revamped

Overview

Order of Operations

The order a controller loads the model, core libraries, helpers, and any other resources is important.

Priorities

  1. Module
  2. Application
  3. System

That

Framework Methods and Functions

Extending

Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular category. There are URL Helpers, that assist in creating links, there are Form Helpers that help you create form elements, Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies, File Helpers help you deal with files, etc.

Unlike most other systems in CodeIgniter, Helpers are not written in an Object Oriented format. They are simple, procedural functions. Each helper function performs one specific task, with no dependence on other functions.

CodeIgniter does not load Helper Files by default, so the first step in using a Helper is to load it. Once loaded, it becomes globally available in your controller <../general/controllers> and views <../general/views>.

Helpers are typically stored in your system/helpers, or application/helpers directory. CodeIgniter will look first in your application/helpers directory. If the directory does not exist or the specified helper is not located there CI will instead look in your global system/helpers/ directory.

Loading a Helper

Loading a helper file is quite simple using the following method:

$this->load->helper('name');

Where name is the file name of the helper, without the .php file extension or the “helper” part.

For example, to load the URL Helper file, which is named url_helper.php, you would do this:

$this->load->helper('url');

A helper can be loaded anywhere within your controller methods (or even within your View files, although that’s not a good practice), as long as you load it before you use it. You can load your helpers in your controller constructor so that they become available automatically in any function, or you can load a helper in a specific function that needs it.

Note

The Helper loading method above does not return a value, so don’t try to assign it to a variable. Just use it as shown.

Loading Multiple Helpers

If you need to load more than one helper you can specify them in an array, like this:

$this->load->helper(
        array('helper1', 'helper2', 'helper3')
);
Auto-loading Helpers

If you find that you need a particular helper globally throughout your application, you can tell CodeIgniter to auto-load it during system initialization. This is done by opening the application/config/autoload.php file and adding the helper to the autoload array.

Using a Helper

Once you’ve loaded the Helper File containing the function you intend to use, you’ll call it the way you would a standard PHP function.

For example, to create a link using the anchor() function in one of your view files you would do this:

<?php echo anchor('blog/comments', 'Click Here');?>

Where “Click Here” is the name of the link, and “blog/comments” is the URI to the controller/method you wish to link to.

“Extending” Helpers

To “extend” Helpers, create a file in your application/helpers/ folder with an identical name to the existing Helper, but prefixed with MY_ (this item is configurable. See below.).

If all you need to do is add some functionality to an existing helper - perhaps add a function or two, or change how a particular helper function operates - then it’s overkill to replace the entire helper with your version. In this case it’s better to simply “extend” the Helper.

Note

The term “extend” is used loosely since Helper functions are procedural and discrete and cannot be extended in the traditional programmatic sense. Under the hood, this gives you the ability to add to or or to replace the functions a Helper provides.

For example, to extend the native Array Helper you’ll create a file named application/helpers/MY_array_helper.php, and add or override functions:

// any_in_array() is not in the Array Helper, so it defines a new function
function any_in_array($needle, $haystack)
{
        $needle = is_array($needle) ? $needle : array($needle);

        foreach ($needle as $item)
        {
                if (in_array($item, $haystack))
                {
                        return TRUE;
                }
        }

        return FALSE;
}

// random_element() is included in Array Helper, so it overrides the native function
function random_element($array)
{
        shuffle($array);
        return array_pop($array);
}
How CodeIgniter Extends a Helper

Helpers Array Helper are loaded in the following order.

  1. application/helpers/MY_array_helper.php
  2. system/helpers/array_helper.php
Set Order

When a variable is set multiple times, it retains the last value set. As shown in the following example:

$color = 'red';
$color = 'yellow';
$color = 'green';

echo $color; // 'green'
Skip If Already Set

The CodeIgniter system/helper files are loaded last, setting the value is skipped it’s already set. Similar to the following example:

$color = 'red';
$color = 'yellow';

if ( ! isset($color) ) {
        $color = 'green';
}

echo $color; // 'yellow'
Array Helper

Important

The function_exists() helper is DEPRECATED and is currently only kept for backwards compatibility.

This works because of the if ( ! function_exists('random_element') ) {}

Using a text editor, create a form called upload_form.php. In it, place this code and save it to your system/helpers/ directory

application/helpers/MY_array_helper.php

function random_element($array)
{
        // Change how this helper function operates.
}

system/helpers/array_helper.php

if ( ! function_exists('random_element'))
{
        function random_element($array)
        {
                // Normal helper function operation.
        }
}
Extend
Replace
Override
Setting Your Own Prefix

The filename prefix for “extending” Helpers is the same used to extend libraries and core classes. To set your own prefix, open your application/config/config.php file and look for this item:

$config['subclass_prefix'] = 'MY_';

Please note that all native CodeIgniter libraries are prefixed with CI_ so DO NOT use that as your prefix.

Now What?

In the Table of Contents you’ll find a list of all the available Helper Files. Browse each one to see what they do.

Overriding

Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular category. There are URL Helpers, that assist in creating links, there are Form Helpers that help you create form elements, Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies, File Helpers help you deal with files, etc.

Unlike most other systems in CodeIgniter, Helpers are not written in an Object Oriented format. They are simple, procedural functions. Each helper function performs one specific task, with no dependence on other functions.

CodeIgniter does not load Helper Files by default, so the first step in using a Helper is to load it. Once loaded, it becomes globally available in your controller <../general/controllers> and views <../general/views>.

Helpers are typically stored in your system/helpers, or application/helpers directory. CodeIgniter will look first in your application/helpers directory. If the directory does not exist or the specified helper is not located there CI will instead look in your global system/helpers/ directory.

Loading a Helper

Loading a helper file is quite simple using the following method:

$this->load->helper('name');

Where name is the file name of the helper, without the .php file extension or the “helper” part.

For example, to load the URL Helper file, which is named url_helper.php, you would do this:

$this->load->helper('url');

A helper can be loaded anywhere within your controller methods (or even within your View files, although that’s not a good practice), as long as you load it before you use it. You can load your helpers in your controller constructor so that they become available automatically in any function, or you can load a helper in a specific function that needs it.

Note

The Helper loading method above does not return a value, so don’t try to assign it to a variable. Just use it as shown.

Loading Multiple Helpers

If you need to load more than one helper you can specify them in an array, like this:

$this->load->helper(
        array('helper1', 'helper2', 'helper3')
);
Auto-loading Helpers

If you find that you need a particular helper globally throughout your application, you can tell CodeIgniter to auto-load it during system initialization. This is done by opening the application/config/autoload.php file and adding the helper to the autoload array.

Using a Helper

Once you’ve loaded the Helper File containing the function you intend to use, you’ll call it the way you would a standard PHP function.

For example, to create a link using the anchor() function in one of your view files you would do this:

<?php echo anchor('blog/comments', 'Click Here');?>

Where “Click Here” is the name of the link, and “blog/comments” is the URI to the controller/method you wish to link to.

“Extending” Helpers

To “extend” Helpers, create a file in your application/helpers/ folder with an identical name to the existing Helper, but prefixed with MY_ (this item is configurable. See below.).

If all you need to do is add some functionality to an existing helper - perhaps add a function or two, or change how a particular helper function operates - then it’s overkill to replace the entire helper with your version. In this case it’s better to simply “extend” the Helper.

Note

The term “extend” is used loosely since Helper functions are procedural and discrete and cannot be extended in the traditional programmatic sense. Under the hood, this gives you the ability to add to or or to replace the functions a Helper provides.

For example, to extend the native Array Helper you’ll create a file named application/helpers/MY_array_helper.php, and add or override functions:

// any_in_array() is not in the Array Helper, so it defines a new function
function any_in_array($needle, $haystack)
{
        $needle = is_array($needle) ? $needle : array($needle);

        foreach ($needle as $item)
        {
                if (in_array($item, $haystack))
                {
                        return TRUE;
                }
        }

        return FALSE;
}

// random_element() is included in Array Helper, so it overrides the native function
function random_element($array)
{
        shuffle($array);
        return array_pop($array);
}
How CodeIgniter Extends a Helper

Helpers Array Helper are loaded in the following order.

  1. application/helpers/MY_array_helper.php
  2. system/helpers/array_helper.php
Set Order

When a variable is set multiple times, it retains the last value set. As shown in the following example:

$color = 'red';
$color = 'yellow';
$color = 'green';

echo $color; // 'green'
Skip If Already Set

The CodeIgniter system/helper files are loaded last, setting the value is skipped it’s already set. Similar to the following example:

$color = 'red';
$color = 'yellow';

if ( ! isset($color) ) {
        $color = 'green';
}

echo $color; // 'yellow'
Array Helper

Important

The function_exists() helper is DEPRECATED and is currently only kept for backwards compatibility.

This works because of the if ( ! function_exists('random_element') ) {}

Using a text editor, create a form called upload_form.php. In it, place this code and save it to your system/helpers/ directory

application/helpers/MY_array_helper.php

function random_element($array)
{
        // Change how this helper function operates.
}

system/helpers/array_helper.php

if ( ! function_exists('random_element'))
{
        function random_element($array)
        {
                // Normal helper function operation.
        }
}
Extend
Replace
Override
Setting Your Own Prefix

The filename prefix for “extending” Helpers is the same used to extend libraries and core classes. To set your own prefix, open your application/config/config.php file and look for this item:

$config['subclass_prefix'] = 'MY_';

Please note that all native CodeIgniter libraries are prefixed with CI_ so DO NOT use that as your prefix.

Now What?

In the Table of Contents you’ll find a list of all the available Helper Files. Browse each one to see what they do.

Replacing

Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular category. There are URL Helpers, that assist in creating links, there are Form Helpers that help you create form elements, Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies, File Helpers help you deal with files, etc.

Unlike most other systems in CodeIgniter, Helpers are not written in an Object Oriented format. They are simple, procedural functions. Each helper function performs one specific task, with no dependence on other functions.

CodeIgniter does not load Helper Files by default, so the first step in using a Helper is to load it. Once loaded, it becomes globally available in your controller <../general/controllers> and views <../general/views>.

Helpers are typically stored in your system/helpers, or application/helpers directory. CodeIgniter will look first in your application/helpers directory. If the directory does not exist or the specified helper is not located there CI will instead look in your global system/helpers/ directory.

Loading a Helper

Loading a helper file is quite simple using the following method:

$this->load->helper('name');

Where name is the file name of the helper, without the .php file extension or the “helper” part.

For example, to load the URL Helper file, which is named url_helper.php, you would do this:

$this->load->helper('url');

A helper can be loaded anywhere within your controller methods (or even within your View files, although that’s not a good practice), as long as you load it before you use it. You can load your helpers in your controller constructor so that they become available automatically in any function, or you can load a helper in a specific function that needs it.

Note

The Helper loading method above does not return a value, so don’t try to assign it to a variable. Just use it as shown.

Loading Multiple Helpers

If you need to load more than one helper you can specify them in an array, like this:

$this->load->helper(
        array('helper1', 'helper2', 'helper3')
);
Auto-loading Helpers

If you find that you need a particular helper globally throughout your application, you can tell CodeIgniter to auto-load it during system initialization. This is done by opening the application/config/autoload.php file and adding the helper to the autoload array.

Using a Helper

Once you’ve loaded the Helper File containing the function you intend to use, you’ll call it the way you would a standard PHP function.

For example, to create a link using the anchor() function in one of your view files you would do this:

<?php echo anchor('blog/comments', 'Click Here');?>

Where “Click Here” is the name of the link, and “blog/comments” is the URI to the controller/method you wish to link to.

“Extending” Helpers

To “extend” Helpers, create a file in your application/helpers/ folder with an identical name to the existing Helper, but prefixed with MY_ (this item is configurable. See below.).

If all you need to do is add some functionality to an existing helper - perhaps add a function or two, or change how a particular helper function operates - then it’s overkill to replace the entire helper with your version. In this case it’s better to simply “extend” the Helper.

Note

The term “extend” is used loosely since Helper functions are procedural and discrete and cannot be extended in the traditional programmatic sense. Under the hood, this gives you the ability to add to or or to replace the functions a Helper provides.

For example, to extend the native Array Helper you’ll create a file named application/helpers/MY_array_helper.php, and add or override functions:

// any_in_array() is not in the Array Helper, so it defines a new function
function any_in_array($needle, $haystack)
{
        $needle = is_array($needle) ? $needle : array($needle);

        foreach ($needle as $item)
        {
                if (in_array($item, $haystack))
                {
                        return TRUE;
                }
        }

        return FALSE;
}

// random_element() is included in Array Helper, so it overrides the native function
function random_element($array)
{
        shuffle($array);
        return array_pop($array);
}
How CodeIgniter Extends a Helper

Helpers Array Helper are loaded in the following order.

  1. application/helpers/MY_array_helper.php
  2. system/helpers/array_helper.php
Set Order

When a variable is set multiple times, it retains the last value set. As shown in the following example:

$color = 'red';
$color = 'yellow';
$color = 'green';

echo $color; // 'green'
Skip If Already Set

The CodeIgniter system/helper files are loaded last, setting the value is skipped it’s already set. Similar to the following example:

$color = 'red';
$color = 'yellow';

if ( ! isset($color) ) {
        $color = 'green';
}

echo $color; // 'yellow'
Array Helper

Important

The function_exists() helper is DEPRECATED and is currently only kept for backwards compatibility.

This works because of the if ( ! function_exists('random_element') ) {}

Using a text editor, create a form called upload_form.php. In it, place this code and save it to your system/helpers/ directory

application/helpers/MY_array_helper.php

function random_element($array)
{
        // Change how this helper function operates.
}

system/helpers/array_helper.php

if ( ! function_exists('random_element'))
{
        function random_element($array)
        {
                // Normal helper function operation.
        }
}
Extend
Replace
Override
Setting Your Own Prefix

The filename prefix for “extending” Helpers is the same used to extend libraries and core classes. To set your own prefix, open your application/config/config.php file and look for this item:

$config['subclass_prefix'] = 'MY_';

Please note that all native CodeIgniter libraries are prefixed with CI_ so DO NOT use that as your prefix.

Now What?

In the Table of Contents you’ll find a list of all the available Helper Files. Browse each one to see what they do.

This

That

This

That

Installation

Module Path Configuration

The Default Path

The module path defaults to APPPATH/modules/.

Custom Module Paths

Custom module paths are set using the $config['modules_locations'] configuration directive in the application/config.php file.

Note

Multiple module paths may be configured.

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

Important

Modules with the same name that exist in multiple locations may have unexpected results. Resources are loaded in the order found in the the configuration directive $config['modules_locations']. The last resource found is the one that is used.

Helper Functions

Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular category. There are URL Helpers, that assist in creating links, there are Form Helpers that help you create form elements, Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies, File Helpers help you deal with files, etc.

Unlike most other systems in CodeIgniter, Helpers are not written in an Object Oriented format. They are simple, procedural functions. Each helper function performs one specific task, with no dependence on other functions.

CodeIgniter does not load Helper Files by default, so the first step in using a Helper is to load it. Once loaded, it becomes globally available in your controller <../general/controllers> and views <../general/views>.

Helpers are typically stored in your system/helpers, or application/helpers directory. CodeIgniter will look first in your application/helpers directory. If the directory does not exist or the specified helper is not located there CI will instead look in your global system/helpers/ directory.

Loading a Helper

Loading a helper file is quite simple using the following method:

$this->load->helper('name');

Where name is the file name of the helper, without the .php file extension or the “helper” part.

For example, to load the URL Helper file, which is named url_helper.php, you would do this:

$this->load->helper('url');

A helper can be loaded anywhere within your controller methods (or even within your View files, although that’s not a good practice), as long as you load it before you use it. You can load your helpers in your controller constructor so that they become available automatically in any function, or you can load a helper in a specific function that needs it.

Note

The Helper loading method above does not return a value, so don’t try to assign it to a variable. Just use it as shown.

Loading Multiple Helpers

If you need to load more than one helper you can specify them in an array, like this:

$this->load->helper(
        array('helper1', 'helper2', 'helper3')
);

Auto-loading Helpers

If you find that you need a particular helper globally throughout your application, you can tell CodeIgniter to auto-load it during system initialization. This is done by opening the application/config/autoload.php file and adding the helper to the autoload array.

Using a Helper

Once you’ve loaded the Helper File containing the function you intend to use, you’ll call it the way you would a standard PHP function.

For example, to create a link using the anchor() function in one of your view files you would do this:

<?php echo anchor('blog/comments', 'Click Here');?>

Where “Click Here” is the name of the link, and “blog/comments” is the URI to the controller/method you wish to link to.

“Extending” Helpers

To “extend” Helpers, create a file in your application/helpers/ folder with an identical name to the existing Helper, but prefixed with MY_ (this item is configurable. See below.).

If all you need to do is add some functionality to an existing helper - perhaps add a function or two, or change how a particular helper function operates - then it’s overkill to replace the entire helper with your version. In this case it’s better to simply “extend” the Helper.

Note

The term “extend” is used loosely since Helper functions are procedural and discrete and cannot be extended in the traditional programmatic sense. Under the hood, this gives you the ability to add to or or to replace the functions a Helper provides.

For example, to extend the native Array Helper you’ll create a file named application/helpers/MY_array_helper.php, and add or override functions:

// any_in_array() is not in the Array Helper, so it defines a new function
function any_in_array($needle, $haystack)
{
        $needle = is_array($needle) ? $needle : array($needle);

        foreach ($needle as $item)
        {
                if (in_array($item, $haystack))
                {
                        return TRUE;
                }
        }

        return FALSE;
}

// random_element() is included in Array Helper, so it overrides the native function
function random_element($array)
{
        shuffle($array);
        return array_pop($array);
}
How CodeIgniter Extends a Helper

Helpers Array Helper are loaded in the following order.

  1. application/helpers/MY_array_helper.php
  2. system/helpers/array_helper.php
Set Order

When a variable is set multiple times, it retains the last value set. As shown in the following example:

$color = 'red';
$color = 'yellow';
$color = 'green';

echo $color; // 'green'
Skip If Already Set

The CodeIgniter system/helper files are loaded last, setting the value is skipped it’s already set. Similar to the following example:

$color = 'red';
$color = 'yellow';

if ( ! isset($color) ) {
        $color = 'green';
}

echo $color; // 'yellow'
Array Helper

Important

The function_exists() helper is DEPRECATED and is currently only kept for backwards compatibility.

This works because of the if ( ! function_exists('random_element') ) {}

Using a text editor, create a form called upload_form.php. In it, place this code and save it to your system/helpers/ directory

application/helpers/MY_array_helper.php

function random_element($array)
{
        // Change how this helper function operates.
}

system/helpers/array_helper.php

if ( ! function_exists('random_element'))
{
        function random_element($array)
        {
                // Normal helper function operation.
        }
}
Extend
Replace
Override
Setting Your Own Prefix

The filename prefix for “extending” Helpers is the same used to extend libraries and core classes. To set your own prefix, open your application/config/config.php file and look for this item:

$config['subclass_prefix'] = 'MY_';

Please note that all native CodeIgniter libraries are prefixed with CI_ so DO NOT use that as your prefix.

Now What?

In the Table of Contents you’ll find a list of all the available Helper Files. Browse each one to see what they do.

This

That

Class Reference

core/MY_Loader.php

Warning

The class reference below uses tk.phpautodoc to automatically generate the content. It uses the phpDocumentor format. Some DocBlock tags may not be supported, formatting may not render properly, content may not be missing, or content may not load at all.

Class Reference

class MY_Loader

Extend, Override, Replace the Loader Core Class

When adding functionality to an existing library, the normal method is to extend the parent class in CodeIgniter. MY_Loader extends CI_Loader

The class hierarchy effectivly results in the following object inheritance. MY_Loader extends MX_Loader extends CI_Loader

@package third_party/MX/Loader.php

@subpackage MX_Loader

core/MY_Router.php

Warning

The class reference below uses tk.phpautodoc to automatically generate the content. It uses the phpDocumentor format. Some DocBlock tags may not be supported, formatting may not render properly, content may not be missing, or content may not load at all.

Class Reference

class MY_Router

Extend, Override, Replace the Router Core Class

When adding functionality to an existing library, the normal method is to extend the parent class in CodeIgniter. MY_Router extends CI_Router

The class hierarchy effectivly results in the following object inheritance. MY_Router extends MX_Router extends CI_Router

@package third_party/MX/Router.php

@subpackage MX_Router

MX/Base.php

Warning

The class reference below uses tk.phpautodoc to automatically generate the content. It uses the phpDocumentor format. Some DocBlock tags may not be supported, formatting may not render properly, content may not be missing, or content may not load at all.

Class Reference

class CI
property $APP
__construct()

MX/Ci.php

Warning

The class reference below uses tk.phpautodoc to automatically generate the content. It uses the phpDocumentor format. Some DocBlock tags may not be supported, formatting may not render properly, content may not be missing, or content may not load at all.

Class Reference

class CI
property $APP
__construct()

MX/Config.php

Warning

The class reference below uses tk.phpautodoc to automatically generate the content. It uses the phpDocumentor format. Some DocBlock tags may not be supported, formatting may not render properly, content may not be missing, or content may not load at all.

Class Reference

class MX_Config

Modular Extensions Revamped - HMVC-RV

Revamped version of the Wiredesignz Modular Extensions - HMVC, orignally adapted from the CodeIgniter Core Classes.

This content is released under the MIT License (MIT)

Copyright (c) 2014 - 2016, British Columbia Institute of Technology Copyright (c) 2015 Wiredesignz Copyright (c) 2017 INVITE Communications Co., Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

load($file = config, $use_sections = FALSE, $fail_gracefully = FALSE)

Load Config File

@param string $file Configuration file name @param bool $use_sections Whether configuration values should be loaded into their own section @param bool $fail_gracefully Whether to just return FALSE or display an error message @return bool TRUE if the file was loaded correctly or FALSE on failure

MX/Controller.php

Warning

The class reference below uses tk.phpautodoc to automatically generate the content. It uses the phpDocumentor format. Some DocBlock tags may not be supported, formatting may not render properly, content may not be missing, or content may not load at all.

Class Reference

class MX_Controller
property $autoload
__construct()
__get($class)

MX/Lang.php

Warning

The class reference below uses tk.phpautodoc to automatically generate the content. It uses the phpDocumentor format. Some DocBlock tags may not be supported, formatting may not render properly, content may not be missing, or content may not load at all.

Class Reference

class MX_Lang

Override the Language Class

When adding functionality to an existing library, the normal method is to extend the parent class in CodeIgniter. MY_Loader extends CI_Loader

@package third_party/MX/Lang.php @subpackage MX_Llang

load($langfile, $lang, $return = FALSE, $add_suffix = TRUE, $alt_path, $_module)

Load Language

@uses Modules::mx_element_path() @uses Modules::mx_element_pathinfo() @uses Modules::mx_element_track() @uses Modules::mx_module_paths()

@param string|array $langfile Language files @return object

MX/Loader.php

Warning

The class reference below uses tk.phpautodoc to automatically generate the content. It uses the phpDocumentor format. Some DocBlock tags may not be supported, formatting may not render properly, content may not be missing, or content may not load at all.

Class Reference

class MX_Loader

Modular Extensions Revamped - HMVC-RV

Revamped version of the Wiredesignz Modular Extensions - HMVC, orignally adapted from the CodeIgniter Core Classes.

This content is released under the MIT License (MIT)

Copyright (c) 2014 - 2016, British Columbia Institute of Technology Copyright (c) 2015 Wiredesignz Copyright (c) 2017 INVITE Communications Co., Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

property $_ci_plugins
property $_ci_cached_vars
initialize($controller = NULL)

Initialize the loader variables *

_add_module_paths($module)

Add a module path loader variables *

database($params, $return = FALSE, $query_builder = NULL)

Load the database drivers *

helper($helpers = array())

Helper Loader

@uses Modules::mx_element_path()

@uses Modules::mx_element_pathinfo()

@uses Modules::mx_element_track()

@uses Modules::mx_module_paths

@param string|array $helpers Helper name(s)

@return object

helpers($helpers = array())

Load Helpers

An alias for the helper() method in case the developer has written the plural form of it.

@uses MX_Loader::helper() @param string|array $helpers Helper name(s) @return object

library($library, $params = NULL, $object_name = NULL)

Load a module library *

libraries($libraries)

Load an array of libraries *

model($model, $object_name = NULL, $connect = FALSE)

Load a module model *

models($models)

Load an array of models *

module($module, $params = NULL)

Load a module controller *

modules($modules)

Load an array of controllers *

plugin($plugin)

Load a module plugin *

plugins($plugins)

Load an array of plugins *

view($view, $vars = array(), $return = FALSE)

Load a module view *

__get($class)
_ci_load($_ci_data)
_autoloader($autoload)

Autoload module items *

MX/Modules.php

Warning

The class reference below uses tk.phpautodoc to automatically generate the content. It uses the phpDocumentor format. Some DocBlock tags may not be supported, formatting may not render properly, content may not be missing, or content may not load at all.

Class Reference

MX/Router.php

Warning

The class reference below uses tk.phpautodoc to automatically generate the content. It uses the phpDocumentor format. Some DocBlock tags may not be supported, formatting may not render properly, content may not be missing, or content may not load at all.

Class Reference

class MX_Router
property $module
fetch_module()
locate($segments)

Locate the controller *

set_class($class)

PHP Markup

The Awesome Class

class Cool\Namespace\Awesome

The awesome class does awesome things. Instantiate like so:

$awesome = new Awesome('param');

static Cool\Namespace\Awesome::someStaticMethod($someParam)

This method is static. See the .rst source file for how this is defined. Also notice that this method appears in the TOC, there is no section heading in the actual body of the document. This is because of a custom hidden role which hides the heading in the body, but lets Sphinx render it in the TOC. If you just put a heading there without the “hidden” part, you’d get the same result, except that the heading would show in the content as well, thus duplicating the function name.

Parameters:
  • $someParam (string) – A parameter needed by the method
Returns:

void, or throws an \InvalidArgumentException if the param is invalid

Usage:

Awesome::someStaticMethod($someParam);

Cool\Namespace\Awesome::anotherMethod()

Notice that this method is not static, and thus lacks the “static” prefix in its title. For more example of directives you can use with PHPDomain, see here.

Returns:null or string

Usage:

echo $awesome->anotherMethod(); // Some result

Keep adding methods like this for everything you want to document. It is recommended to only document public methods like this. Private and protected methods should stay isolated and only documented in the source code.

phpautodoc

phpautomodule

Class Only
class somethingNew

@author My Name @author My Name <my.name@example.com>

class anotherClass
Class & Members
class somethingNew

@author My Name @author My Name <my.name@example.com>

myFunction($myArgument)

A summary informing the user what the associated element does.

A description, that can span multiple lines, to go _in-depth_ into the details of this element and to provide some background information or textual references.

@param string $myArgument With a description of this argument, these may also
span multiple lines.

@return void

anotherFunction($myArgument)

A summary informing the user what the associated element does.

A description, that can span multiple lines, to go _in-depth_ into the details of this element and to provide some background information or textual references.

@author My Name

@author My Name <my.name@example.com>

@param string $myArgument With a description of this argument,

@return void

class anotherClass
one()

@return voice

phpautoclass

Named Class
class anotherClass
one()

@return voice

Auto Detect

Does not work correctly

phpautofunction

Named Function
count()

@deprecated @deprecated 1.0.0 @deprecated No longer used by internal code and not recommended. @deprecated 1.0.0 No longer used by internal code and not recommended.

PHP Domain

class DateTime

Datetime class

setDate($year, $month, $day)

Set the date.

Parameters:
  • $year (int) – The year.
  • $month (int) – The month.
  • $day (int) – The day.
Returns:

Either false on failure, or the datetime object for method chaining.

setTime($hour, $minute[, $second])

Set the time.

Parameters:
  • $hour (int) – The hour
  • $minute (int) – The minute
  • $second (int) – The second
Returns:

Either false on failure, or the datetime object for method chaining.

constant ATOM

Y-m-dTH:i:sP

Overview

HMVC stands for Hierarchical Model View Controller

Modular Extensions makes 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.

Modular Extensions Revamped - HMVC-RV

External hyperlinks, like Modular Extensions - HMVC.

Why?

While attempting to create a module template, functionality that’s available in the current version of CodeIgniter would not work in the module. The HMVC was missing some CodeIgniter functionality that has existed since v2.0.1, such as:

CodeIgniter v2.0.0:
 
  • Applying the sub-class prefix option when loading classes
CodeIgniter v2.0.1:
 
  • Multiple Environments
  • Support for environment-specific configuration files

This led to the discovery that the current Wiredesignz version goes back to before CodeIgniter v2.0.0 was released. This can be seen throughout the code when, compared against later versions of CodeIgniter. Some of the design and architectural changes in CodeIgniter are not reflected in the HMVC. [1]

Goals of this Project

  • Improved Documentation
  • Improved Functionality
  • Multi-Environment Support
  • Hosted on GitHub
The MIT License (MIT)
  • Copyright (c) 2014 - 2017, British Columbia Institute of Technology
  • Copyright (c) 2015 Wiredesignz
  • Copyright (c) 2017 INVITE Communications Co., Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

[1]Sincere appreciation goes towards Wiredesignz for the original code, the contributing developers, and all those who have maintained the HMVC to support later versions of CodeIgniter.