Because I can never remember how to do this and because it’s not that easy to find on google I have copied the info here.
If you want to add a folder to the application directory and then have classes within that directory autoload, for instance you add a folder ‘objects’ (application/systems) that contain classes like Application_System_One. This would work for any Application_ classes and its exactly what the Zend Framework autoloader does when it inits the default resorces like application forms, models, services etc.
Here’s what you need to do:
Full credit goes to http://pietervogelaar.nl/ for this copy and paste.
This week I wanted to created the folder “application/grids/” to store my grids in. For example the path to the grid is “application/grids/Product.php”.
The code inside this PHP file:
123 class Application_Grid_Product{}You will now get the error “Fatal error: Class ‘Application_Grid_Product’ not found”. The new path must be added to the Zend Autoloader in order to load the required classes. Your bootstrap must look like this:
1234567 class Bootstrap extends Zend_Application_Bootstrap_Bootstrap{protected function _initLoaderResources(){$this->getResourceLoader()->addResourceType('grid', 'grids/', 'Grid');}}And you’re done! It would be even nicer to configure this in the application.ini, but unfortunately there is no way to add a resource type trough the application.ini at the moment.
Thanks for your help!