Reputation: 2980
I have Zend Framework 1.12 application with several modules. So far everything worked well. But I wanted to add mappers to my application and Zend Framework can not find mapper class.
Structure of the project:
-application
-modules
-api
-otms
-models
-Mapper
FormToOnix2.php
-FeedFile.php
Mapper file looks like:
class Otms_Model_Mapper_FormToOnix2
{
...
}
In application.ini I added "Otms_" prefix for autoloading:
autoloaderNamespaces.otms[] = "Otms_"
But when I try to create mapper object from controller
$test = new Otms_Model_Mapper_FormToOnix2();
I receive the following error message
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
At the same time if I try to create object of another Otms model, like :
$file = new Otms_Model_FeedFile();
Everything works fine. How to fix problem with mapper loading?
Upvotes: 2
Views: 875
Reputation: 2980
Ok, I read Zend Documentation about autoloader and module resources loader. So,
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.
And this mapping scheme look like this:
forms/ => Form
models/ => Model
DbTable/ => Model_DbTable
mappers/ => Model_Mapper
plugins/ => Plugin
services/ => Service
views/
helpers => View_Helper
filters => View_Filter
So, if you want to add a directory with mappers you should name it "Mappers" not "Mapper". That solved my problem.
Upvotes: 2