我正在拔掉所有的头发……一直在搜索每一个帖子,如果有人能指出我一个有效的例子,我将不胜感激.
加入doc: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()”.每次只调用控制器的构造函数.
目标是将自包含的MVC构建为模块并由其他控制器使用. 但无论我做什么,它只调用构造函数,方法不调用. 几个星期前我开始使用HMVC,我是否遗漏了文档中的某些内容,或者它是不是以这种方式使用? 这是设置:
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
附加说明:脚本没有错误或警告.它只是静静地调用构造函数. 解决方法: 这款HMVC适合我.我正在研究一个使用这个HMVC的项目. 只需编辑third_party / MX / Modules.PHP,如下面的链接所示,并告诉我响应.
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/pull-request/5/return-error-messages-instead-of-logging/diff (编辑:北几岛)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|