-
Notifications
You must be signed in to change notification settings - Fork 0
Modular Separation
[h3]Description[/h3] Modular Separation allows you to use modules for code organization in your application while only using a single controller per request. Instead of placing all of your controllers, models and views in the same folders you can have a "module" for each section of your site then place the MVC elements in there. This is known as Modular MVC.
You should be able to take any CodeIgniter application and place it into a module and it should work without alteration. However routes might need altering to allow for the added separation of a module.
[h3]Features[/h3]
- Modules can be stored in several locations by modifying MY_Router.php
- Each module may contain a config/routes.php file where routing and a default controller can be defined for that module. The default controller should be set using $route['module_name'] and [b]NOT[/b] $route['default_controller'].
- $route['404'] can be set in application/routes.php to send all 404 requests to a certain module.
- Controllers may be loaded from application/controllers.
- Controllers may also be loaded from module/controllers.
- All module controllers are accessible from the URL via module/controller/method or simply module/method if the module and controller names match.
- You can still use _remap() in your controllers
[h3]Module Directory Structure[/h3] Image:hmvc_structure.gif
[h3]But that sounds like...[/h3]
[url=/wiki/Modular_Extensions_-_HMVC/]Modular Extensions (HMVC)[/url] or [url=/wiki/Matchbox/]Matchbox[/url]. The two systems offer similar features but are not as up to date as Modular Separation.
Modular Extensions is an older system that maintains support for PHP 4 and allows controllers to be called between each other. This is a feature that is very useful in certain situations but more often than not just confuses new CodeIgniter developers who over-use this memory-hungry feature instead of just placing shared logic into libraries.
Modular Separation drops PHP 4 support and adds many awesome new features not available in ME such as $route['404'] routing for your errors, multiple module locations and more.
Matchbox is a great system but also maintains support for PHP 4 and uses additional $this->load->module_xxxx() calls which break standard CodeIgniter practices. Modular Separation uses $this->load->xxxx('module/item') instead.
[h3]Download[/h3]
CodeIgniter 1.7.x - 2.0-dev: [url=http://bitbucket.org/philsturgeon/codeigniter-modular-separation/get/v2.1.zip]v2.1[/url]
[h3]Discuss[/h3]
[url=http://codeigniter.com/forums/viewthread/121820]Forum thread[/url]
Developed by: wiredesignz Modified by: Phil Sturgeon