Migrating to ZF 1.8: Zend_Application, Zend_Application_Bootstrap
I finally found some time to adopt one of my older web applications from Zend Framework 1.6 to Zend Framework > 1.8 (actually, I shifted to ZF 1.10.6). Actually, the only negative point I found was the confusing terminology (up to ZF 1.8 a plugin was a plugin, now a plugin is either a Zend_Controller_Plugin or a resource plugin used in the bootstrap).
However, the positive aspects are enormous. Your bootstrap is no longer the black sheep of spaghetti code in your familiy of perfectly designed object-oriented code. This (and the fact that you may write your own bootstrap resources) enables you to easily re-use your bootstrap in different applications!
Another great advantage is the fact that the return value of each resource class will be accessible anywhere in your source. For instance, if you have something like this in your bootstrap…
protected function _initDatabase()
{
$resource = $this->getPluginResource('db');
$db = $resource->getDbAdapter();
return $db;
}
…you may access the database adapter later on in your application by simply using
$db = $bootstrap->getResource('Databases');
If you want to access the resource in your controller use
$db = $this->getInvokeArg('bootstrap')->getResource('Database');
If you would like to find out more about Zend_Application and bootstrapping in ZF > 1.8 here are two great articles written by Matthew Weier O’Phinney in his blog:
Quick Start to Zend_Application_Bootstrap
Creating Re-Usable Zend_Application Resource Plugins Plugins.html
Have fun!
No related posts.

CSS Zend Garden
KingCrunchs kleine Welt