-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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 HMVC (Hierarchical 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.
- $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]
Do not confuse Modular Separation with Modular Extensions (HMVC). ME is an older system that maintains support for PHP 4 and allows controllers to be called between each other. Modular Separation drops PHP 4 support and adds many awesome new features not available in ME.
Modular Separation works the same way as Zach’s Matchbox, But is much faster in execution and does the job without using additional module_xxxx() calls. The main reason for the speed improvement is lots of clever PHP 5-only syntax is used, while Matchbox supports PHP 4 too.
[h3]Download[/h3]
[url=http://codeigniter.com/?ACT=51&fid=58&aid=10003_6avIWaB8yxJCM37u2pnH&board_id=2]Download v1.11[/url]
[i]Phil Sturgeon has patched v1.11 to work with CodeIgniter 2.0 and called it [url=http://bitbucket.org/philsturgeon/codeigniter-modular-separation]Modular Separation 2.0[/url] for naming consistency.[/i]
[h3]Discuss[/h3]
[url=http://codeigniter.com/forums/viewthread/121820]Forum thread[/url]
wiredesignz