如何访问 Zend_Framework 中默认模块中的模型?

发布于 2024-12-28 01:52:47 字数 918 浏览 3 评论 0原文

我正在尝试使用 Zend Framework 中的模块使我的应用程序模块化。

这是我的新项目结构:

<块引用> <前><代码>配置/ 应用程序.ini 布局/ 过滤器/ 帮手/ 脚本/ 模块/ 默认/ 表格/ 控制器/ 型号/ 观点/ 行政/ 表格/ 控制器/ 型号/ 观点/ Bootstrap.php

我已在应用程序 .ini 中添加了这些行:

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.params.prefixDefaultModule = false
resources.modules[] =

现在,我可以访问默认目录中的控制器和视图,而无需更改之前配置中的任何内容(我刚刚将控制器/模型/视图移至 module/ 目录中)。

但是,我无法访问默认模块中的模型。

这是当我尝试从控制器访问该模型时显示的错误:

致命错误:在第 138 行 /var/www/.../application/modules/default/controllers/AccountController.php 中找不到类“Model_Account_Edit”

知道吗?

I'm trying to make my application modular using modules in Zend Framework.

Here is my new project structure:

   configs/ 
        application.ini
    layouts/
        filters/
        helpers/
        scripts/
    modules/
        default/
               forms/
               controllers/
               models/
               views/
        admin/
               forms/
               controllers/
               models/
               views/
    Bootstrap.php

I've added these lines in my application .ini:

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.params.prefixDefaultModule = false
resources.modules[] =

I can now access the controllers and views in the default directory without changing anything in my previous configuration (I just moved my controllers/models/views into the module/ directory).

However, I can't access to models located in the default module.

Here is the error displayed when I tried to access to this model from a controller:

Fatal error: Class 'Model_Account_Edit' not found in /var/www/.../application/modules/default/controllers/AccountController.php on line 138

Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

魔法唧唧 2025-01-04 01:52:47

这可能是因为您缺少特定于模块的引导程序。
向每个模块添加一个引导程序文件,它应该可以工作。该类应如下所示:

class Default_Bootstrap extends Zend_Application_Module_Bootstrap{}

将其添加到项目中

modules/
    default/
           forms/
           controllers/
           models/
           views/
           Bootstrap.php

并且您应该准备好开始。

It's probably because you're missing a module specific bootstrap.
Add a bootstrap file to each module and it should work. The class should look something like this:

class Default_Bootstrap extends Zend_Application_Module_Bootstrap{}

Add it to the project

modules/
    default/
           forms/
           controllers/
           models/
           views/
           Bootstrap.php

And you should be ready to go.

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