在 Zend Framework 中调用模块中的模型
我有一个结构,
application
application/modules
application/modules/default
application/modules/default/models
application/modules/admin
application/modules/admin/models
当在管理中调用控制器时,我知道它们必须命名为Admin_TestController
。这工作正常,但我的管理模块中的模型似乎无法加载。我尝试过以各种方式命名它们和文件,但它似乎并不希望能够加载它们。我应该如何命名模块中的文件和模型类才能使用它?我使用自动加载。
I have a structure that is
application
application/modules
application/modules/default
application/modules/default/models
application/modules/admin
application/modules/admin/models
When calling controllers in admin I understand they must be named like Admin_TestController
. This works fine, but my models in my admin module don't seem to be able to load. I have tried naming them and the files in all kinds of ways but it just doesn't seem to want to be able to load them. How should I name the file and model class in a module to be able to use it? I use autoloading.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的引导程序文件是什么样的?这是问题最重要的部分。
非常重要的是(为了自动加载名称空间),每个模块(位于@ application/modules/admin/bootstrap.php)中都有一个引导程序,它至少应该包含:
请注意,它扩展了 Zend_Application_Module_Bootstrap。这完成了为模块的 MVC 注册命名空间的繁重工作。
What do your bootstrap files look like? That is the most import part of problem.
It is very important (in order for the namespaces to autoload) that you you have a bootstrap in each module (located @ application/modules/admin/bootstrap.php) that should contain, at the very least:
Notice that it extends Zend_Application_Module_Bootstrap. This does the heavy lifting of registering the namespaces for the MVC of the module.
正如 Fatmuemoo 指出模块的引导程序应该扩展 Zend_Application_Module_Bootstrap 一样,您也应该
在您的配置中包含它。这是 Zend_Application_Resource_Modules 的文档
As Fatmuemoo states the bootstrap for the module should extend Zend_Application_Module_Bootstrap also you should include
In your config. This is in the docs for Zend_Application_Resource_Modules
看来您需要包含一个引导类,该类为您要使用的模块扩展 Zend_Application_Module_Bootstrap 。检查 这个论坛帖子讨论了类似的问题,看看它是否可以帮助您找到正确的方法。看来您可能需要多个来加载单独的模块。
It seems you need to include a bootstrap class that extends Zend_Application_Module_Bootstrap for the modules you want to use. Check this forum post about a similar issue to see if it helps point you in the right way. Seems you may need more than one to load separate modules.