我有几个模块的Zend Framework 1.12应用程序。到目前为止一切运作良好。但我想在我的应用程序中添加映射器,Zend Framework找不到mapper类。
项目结构:
-application
-modules
-api
-otms
-models
-Mapper
FormToOnix2.php
-FeedFile.php
Mapper文件如下所示:
class Otms_Model_Mapper_FormToOnix2
{
...
}
在application.ini中,我添加了" Otms _"自动加载的前缀:
autoloaderNamespaces.otms[] = "Otms_"
但是当我尝试从控制器
创建mapper对象时 $test = new Otms_Model_Mapper_FormToOnix2();
我收到以下错误消息
include_once(Otms/Model/Mapper/FormToOnix2.php): failed to open stream: No such file or directory in <b>/cloudware/library/Zend/Loader.php</b> on line 146
同时,如果我尝试创建另一个Otms模型的对象,例如:
$file = new Otms_Model_FeedFile();
一切正常。如何修复mapper加载的问题?
答案 0 :(得分:2)
好的,我阅读了有关自动加载器和模块资源加载器的Zend Documentation。所以,
Zend Framework ships with a concrete implementation of Zend_Loader_Autoloader_Resource
that contains resource type mappings that cover the default recommended
the directory structure for Zend Framework MVC applications.
这个映射方案如下所示:
forms/ => Form
models/ => Model
DbTable/ => Model_DbTable
mappers/ => Model_Mapper
plugins/ => Plugin
services/ => Service
views/
helpers => View_Helper
filters => View_Filter
因此,如果要添加带有映射器的目录,则应将其命名为“Mappers”而不是“Mapper”。这解决了我的问题。