Codeigniter + Namespaces + HMVC
Working with namespaces in hmvc is same that part 1. The diference is how we load a namespaced module:
namespace controllers\blog; class user extends \MX_Controller { public function get_comments($id_user){ /* Code */ //[1] $module = $this->load->module('namespace\modulename/classname'); //[2] $module->method($x, $y); // OR [3] \Modules::run('namespace\modulename/classname/method', $x, $y); } } $_ns = __NAMESPACE__;How to load a module
- Load module into a variable. The format is namespace\[backslash]modulename/[slash]classname
- Call the module method
- Run module method statically
Download HMVC module example
2 comments:
Can you please provide me a working copy of HMVC + Namespaces + CI... I've tried but didn't get any success. Please give a working copy
Hi Suraj. I've uploaded an example in this post. Search for 'Download HMVC module example' link.
Post a Comment