codeigniter+HMVC 跨模块调用控制器->方法 [英] codeigniter+HMVC cross module call controller->method

查看:30
本文介绍了codeigniter+HMVC 跨模块调用控制器->方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在拔掉我所有的头发...一直在搜索每一个线程,如果有人能指出一个可行的例子,我将不胜感激.

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

根据文档:https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc我可以使用

modules::run('module/controller/method', $params);
modules::load('module/controller/method', $params);
or
$this->load->module('module/controller');
$this->controller->method();

问题:method()"从未被调用.每次只调用控制器的构造函数.

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

目标是将自包含的 MVC 构建为模块并供其他控制器使用.但无论我做什么,它都只调用构造函数,不调用方法.几周前我开始使用 HMVC,我是否遗漏了文档中的某些内容,或者它没有以这种方式使用?
这是设置:

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:

modules
  |--ztest1
  |   |--controller/c1.php
  |--ztest2
      |--controller/c2.php

class C1 extends MX_Controller {
  function __construct() {
    parent::__construct();
  }
  function index () {
    Modules::run('ztest2/c2/testc2/');
    //Modules::load('ztest2/c2/testc2/');
    //$this->load->module('ztest2/c2/testc2/');
    //$this->c2->testc2();
  }
}

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

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

附加说明:脚本没有错误或警告.它只是静静地调用构造函数.

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

推荐答案

这个 HMVC 很适合我.我现在正在使用这个 HMVC 进行一个项目.只需编辑 third_party/MX/Modules.php,如下面的链接所示,并告诉我响应.

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.

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/pull-request/5/return-error-messages-instead-of-logging/diff

这篇关于codeigniter+HMVC 跨模块调用控制器->方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆