Zend 不自动加载模型
好吧,这让我发疯!
我的目录结构如下:
application
- modules
-- default
--- controllers
--- models
---- DbTable
---- Cachmapper.php
--- views
我的配置文件如下所示
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] =
该应用程序似乎可以工作,如果我导航到本地主机,它会正确地转到索引控制器。但是,由于某种原因它拒绝加载任何模型。
致命错误:在....................................../application/modules/default/controllers/中找不到类“Model_Cachmapper” IndexController.php 第 26 行
有想法吗?
谢谢
Ok, this is driving me nuts!
I have a directory structure as follows:
application
- modules
-- default
--- controllers
--- models
---- DbTable
---- Cachmapper.php
--- views
My config file looks like this
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] =
The application seems to work, if I navigate to localhost, it correctly goes to the index controller. But, for some reason it refuses to load any models.
Fatal error: Class 'Model_Cachmapper' not found in .............................../application/modules/default/controllers/IndexController.php on line 26
Ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是一个适用于 ZF 1.10.x 甚至更早版本的工作版本(至少是其中之一)。
index.php
application.ini - 相关部分
以及 application/Bootstrap.php
Here's a working version (one of them, at least), for ZF 1.10.x and probably earlier, too.
index.php
application.ini - the relevant parts
and in application/Bootstrap.php
我是 ZF 的新手用户,所以这可能不“正确”,但我以这种方式使用数据库模型没有遇到任何问题。
我的目录结构如下所示:
在我的 application/public/index.php 中,我有以下代码:
我的应用程序命名空间是 Application (如果您不知道的话)。
我的数据库模型如下所示(位于 application/models/DbTable 中:
此外,application/configs/application.ini 的相关部分:
I am a novice ZF user, so this may not be 'correct' but I have had no problems using DB Models this way.
My directory structure looks like this:
In my application/public/index.php I have the following code:
My application namespace is Application (if you couldn't tell).
My database models look like this (located in application/models/DbTable:
Also, the relevant portions of application/configs/application.ini:
我会向模块添加一个引导类,否则模块加载器不知道它。
并存储在 applications/default/Bootstrap.php
http://akrabat.com/modules 有更多信息。
I would add a bootstrap class to the module as otherwise the module loader doesn't know about it.
And store in applications/default/Bootstrap.php
http://akrabat.com/modules has some more info.
将您的模型目录添加到您的 includePaths
我有:
我知道,您的模型位于您的模块下,但应该可以以某种方式执行。也许在引导程序中而不是 application.ini
Att.: Rob
嗨,Rob,
好吧,我很困惑。因为我实际上买了你的书《Zend Framework In Action》。
在源代码中“Places”应用程序的引导程序中,您有以下内容。
我知道源代码是为较旧的 ZF 版本编写的。我当前正在开发的应用程序基于 Zend_Application,如果我从 includePaths 中删除模型文件夹,加载器将找不到我的模型。
Add your models directory to your includePaths
I have:
I know, your models lies under your modules, but should be possible to do somehow. Maybe in the bootstrap instead of application.ini
Att.: Rob
Hi Rob,
Well i'm confused. Because i actually bought your book 'Zend Framework In Action'.
And in the bootstrap of the 'Places' app in the sourcecode, you have the following.
I know that the source is written for an older ZF version. My current app i'm working on is based on Zend_Application, and if i remove the models folder from my includePaths, the loader can't find my models.