views:

102

answers:

2

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 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".

+1  A: 

if you use a application.ini try this

autoloader.namespace = My
autoloader.resourceTypes.exceptions.path = "library"
autoloader.resourceTypes.exceptions.namespace = "Model"
Nexum
+1  A: 

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_');
takeshin