Reed Reed - 1 year ago 88
PHP Question

codeigniter+HMVC cross module call controller->method

I am pulling all my hair off... Have been searching every thread, would appreciate if someone can point me to a working example.

Accroding to the doc:
I can call another module->controller using

modules::run('module/controller/method', $params);
modules::load('module/controller/method', $params);

Problem: the "method()" is never called. only constructor of the controller is called every time.

The objective is to build self-contained MVCs as module and use by other controllers.
But no matter what I do, it only calls the constructor, method is not called.
I started using HMVC a few weeks ago, did I miss something in the doc or it is not used this way?

Here is the setup:

| |--controller/c1.php

class C1 extends MX_Controller {
function __construct() {
function index () {

class C2 extends MX_Controller {
function __construct() {
echo __FILE__." // ".__CLASS__."/".__FUNCTION__.PHP_EOL;
function testc2(){
echo __FILE__." // ".__CLASS__."/".__FUNCTION__.PHP_EOL;

/app/modules/ztest2/controllers/c2.php // C2/__construct

additional note: no error or warning with the script. It just quietly calls the constructor.

Answer Source

This HMVC works well for me. I'm working on a project using this HMVC now. Just edit third_party/MX/Modules.php as shown in this link below and tell me the response.