Codeigniter 模块化扩展

发布于 2024-09-26 09:02:55 字数 758 浏览 6 评论 0原文

我正在尝试将 模块化扩展 实现到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

幽梦紫曦~ 2024-10-03 09:02:56

如果您从同一模块中的控制器访问模型,则可以使用以下方法加载它:

$this->load->model(‘user_m’);

您只需执行 $this->load->model('module/model_name');当你在模块之间交叉加载时。

只是为了确保您的模型位于此处,对吗?

application/modules/users/models/users_m.php

至于分析器错误:
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:

$this->load->model(‘user_m’);

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?

application/modules/users/models/users_m.php

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/

秋凉 2024-10-03 09:02:56

如果您的文件夹结构如下:

application/
           modules/
                  users/
                       models/
                             users_m.php

然后使用它来调用控制器中的模型

$this->load->model('users/users_m','',TRUE);

if you have folder structure like:

application/
           modules/
                  users/
                       models/
                             users_m.php

then use this to call modelsin you controller

$this->load->model('users/users_m','',TRUE);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文