Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
713uk13m authored and 713uk13m committed Oct 4, 2018
1 parent 1a4931b commit fd3b318
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# CodeIgniter HMVC

### Support development of Modular Extensions - HMVC
### Support development of Modular Extensions - HMVC to WireDesignz

[![Support development](https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FK79XNCUE9P5C)

# Modular Extensions - HMVC

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** 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.

HMVC stands for Hierarchical Model View Controller.
**HMVC** stands for **Hierarchical Model View Controller**.

Module Controllers can be used as normal Controllers or HMVC Controllers and they can be used as widgets to help you build view partials.

Design by **wiredesignz**, thank you verymuch!

### Features:

All controllers can contain an autoload class variable, which holds an array of items to load prior to running the constructor. This can be used together with module/config/autoload.php, however using the $autoload variable only works for that specific controller.
```
```php
<?php
class Xyz extends MX_Controller
{
Expand All @@ -28,7 +30,7 @@ class Xyz extends MX_Controller

The Modules::$locations array may be set in the application/config.php file. ie:

```
```php
<?php
$config['modules_locations'] = array(
APPPATH.'modules/' => '../modules/',
Expand All @@ -39,22 +41,22 @@ Modules::run() output is buffered, so any data returned or output directly from

Controllers can be loaded as class variables of other controllers using

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

or simply

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

if the controller name matches the module name.

Any loaded module controller can then be used like a library, ie:

```
$this->controller->method()
```php
$this->controller->method();
```

, but it has access to its own models and libraries independently from the caller.
Expand All @@ -63,7 +65,9 @@ All module controllers are accessible from the URL via module/controller/method

### Use:

create file application/core/MY_Loader.php with content
I am custom library, now config same rule below

create file ***application/core/MY_Loader.php*** with content

```php
<?php
Expand All @@ -75,7 +79,7 @@ class MY_Loader extends BaseLoader
}
```

create file application/core/MY_Router.php with content
create file **application/core/MY_Router.php** with content

```php
<?php
Expand All @@ -93,8 +97,8 @@ class MY_Router extends BaseRouter

To use HMVC functionality, such as

```
Modules::run()
```php
Modules::run();
```

, controllers must extend the MX_Controller class.
Expand All @@ -103,7 +107,7 @@ To use Modular Separation only, without HMVC, controllers will extend the CodeIg

You must use PHP5 style constructors in your controllers. ie:

```
```php
<?php
class Xyz extends MX_Controller
{
Expand All @@ -120,7 +124,7 @@ All MY_ extension libraries should include (require) their equivalent MX library

Each module may contain a config/routes.php file where routing and a default controller can be defined for that module using:

```
```php
<?php
$route['module_name'] = 'controller_name';
```
Expand All @@ -131,13 +135,13 @@ Controllers may also be loaded from module/controllers sub-directories.

Resources may be cross loaded between modules. ie:

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

Modules::run() is designed for returning view partials, and it will return buffered output (a view) from a controller. The syntax for using modules::run is a URI style segmented string and unlimited variables.

```
```php
<?php
/** module and controller names are different, you must include the method name also, including 'index' **/
modules::run('module/controller/method', $params, $...);
Expand All @@ -153,34 +157,34 @@ modules::run('module', $params, $...);

To call a module controller from within a controller you can use

```
$this->load->module()
```php
$this->load->module();
```

or

```
Modules::load()
```php
Modules::load();
```

and PHP5 method chaining is available for any object loaded by MX. ie:

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

To load languages for modules it is recommended to use the Loader method which will pass the active module name to the Lang instance; ie:

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

The PHP5 spl_autoload feature allows you to freely extend your controllers, models and libraries from application/core or application/libraries base classes without the need to specifically include or require them.

The library loader has also been updated to accommodate some CI 1.7 features: ie Library aliases are accepted in the same fashion as model aliases, and loading config files from the module config directory as library parameters (re: form_validation.php) have beed added.

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

, Returns the loaded config array to your variable.
Expand All @@ -189,7 +193,7 @@ Models and libraries can also be loaded from sub-directories in their respective

When using form validation with MX you will need to extend the CI_Form_validation class as shown below,

```
```php
<?php
/** application/libraries/MY_Form_validation **/
class MY_Form_validation extends CI_Form_validation
Expand All @@ -200,7 +204,7 @@ class MY_Form_validation extends CI_Form_validation

before assigning the current controller as the $CI variable to the form_validation library. This will allow your callback methods to function properly. (This has been discussed on the CI forums also).

```
```php
<?php
class Xyz extends MX_Controller
{
Expand All @@ -218,7 +222,7 @@ class Xyz extends MX_Controller

Using a Module as a view partial from within a view is as easy as writing:

```
```php
<?php echo Modules::run('module/controller/method', $param, $...); ?>
```

Expand Down

0 comments on commit fd3b318

Please sign in to comment.