Codeigniter 模块化扩展
我正在尝试将 模块化扩展 实现到 codeigniter 2 设置中,但我有一个很少有问题。我按照维基上的安装说明进行操作,一切正常。然后我开始尝试并尝试使用它。我所做的就是创建一个名为 users 的新模块,其中包含所需的文件夹,并添加一个名为 users_m 的模型类。然后我尝试从我的欢迎模块控制器加载它。根据维基百科,这应该是非常简单的。我只是将这一行添加
$this->load->model('users/users_m');
到我的欢迎控制器的构造函数中。
不幸的是,此时我遇到了死机白屏。
所以我尝试了别的东西。这次我删除了加载模型行并添加了
$this->output->enable_profiler(TRUE);
这次我显示了欢迎页面并获得了分析器,但在页面顶部我收到了此错误:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI::$profiler
Filename: MX/Loader.php
Line Number: 145
我不知道这两个尝试是否相关,但我的设置显然有问题。有人能指出我正确的方向吗?
I'm trying to implement modular extensions into a codeigniter 2 setup but am having a few problems. I followed the installation instructions on the wiki and everything was working fine. Then I started to play around a bit and try and use it. All I did was create a new module called users with the required folders and added a model class called users_m. I then tried to load this from my welcome module controller. According to the wiki this should be very straightforward. I simply added this line
$this->load->model('users/users_m');
to the constructor of my welcome controller.
Unfortunately at this point I get the white screen of death.
So I tried something else. This time I removed the load model line and added
$this->output->enable_profiler(TRUE);
This time I got the welcome page displayed and I got the profiler, but at the top of the page I got this error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI::$profiler
Filename: MX/Loader.php
Line Number: 145
I don't know if these two tries are related or not, but there's obviously something not right with my setup. Could someone point me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您从同一模块中的控制器访问模型,则可以使用以下方法加载它:
您只需执行
$this->load->model('module/model_name');
当你在模块之间交叉加载时。只是为了确保您的模型位于此处,对吗?
至于分析器错误:
1) 您是否已完成安装第5步并放置模块化扩展core 文件放到 application/core 中?
2)你们有最新版本的HMVC吗? 过去几天对 mx/loader.php 进行了更新。
诗。关于 HMVC 的精彩教程:http://net.tutsplus.com /tutorials/php/hvmc-an-introduction-and-application/
If you accessing the model from the controller in the same module, you can load it using just:
You only have to do
$this->load->model(‘module/model_name’);
when your cross loading between modules.Just to make sure, your model is located here right?
As for the profiler error:
1) Have you done installation step 5 and put the Modular Extensions core files into application/core?
2) Do you have the latest version of HMVC? There have been updates to mx/loader.php in the last couple days.
Ps. great tutorial on HMVC: http://net.tutsplus.com/tutorials/php/hvmc-an-introduction-and-application/
如果您的文件夹结构如下:
然后使用它来调用控制器中的模型
if you have folder structure like:
then use this to call modelsin you controller