What is the autoload class names structure, for the root "library" dir in a Zend Framework 1.10.2 project?
I have a project I created with Zend Framework 1.10.2.
I usually use the application/models directory for new model files I create, and the auto loading is fine, so for example - My_Model_SampleClass is located application/models/SampleClass.php.
However, I have just created a custom Exception class, and it does not fit in the models directory inside the application dir (at least the way I see it, I could be logically wrong), so I've created it in the root "library" dir, but I can't seem to find the开发者_如何学C correct class name + file name to use, so auto loading will be done correctly.
BTW, I use a namespace for all custom classes I use, let's assume it's "My".
if you use a application.ini try this
autoloader.namespace = My
autoloader.resourceTypes.exceptions.path = "library"
autoloader.resourceTypes.exceptions.namespace = "Model"
class My_Exception extends Zend_Exception {}
saved in:
/library/My/Exception.php
in application.ini:
autoloaderNamespaces[] = "My_"
or take a look at resourceLoader
:
// in Bootstrap.php
Zend_Debug::dump($this->_resourceLoader);
You may use it like this:
$this->_resourceLoader->addResourceType('exception', 'exceptions', 'My_');
精彩评论