Zend Framework – Add custom resource type to autoloader
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:
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:
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.
This entry was posted by Pieter Vogelaar on October 4, 2011 at 15:41, and is filed under Zend Framework. Follow any responses to this post through RSS 2.0.You can leave a response or trackback from your own site.
About Pieter Vogelaar (60 posts)
Hi, my name is Pieter Vogelaar. I’m a web developer / DevOps engineer / IT consultant and specialized in high traffic and high profile websites. I love open source and have a great passion for automating and developing things!
At last, someone says this easy!!! Tanks!!