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
1 comment:
Hi Suraj. I've uploaded an example in this post. Search for 'Download HMVC module example' link.
Post a Comment