Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding the Zend Framework Bootstrap process and resource loading from application.ini

I am pretty familiar with Zend Framework details and how most things work. One area that I still don't fully understand is the way Zend Framework loads resources from application.ini.

I understand I can create my own protected _init functions and these will be called automatically during bootstrap.

The Zend Framework documentation is lacking in certain areas.

For example: How and when does the resources.db config options get loaded? I have nothing in my bootstrap that talks about db. Does this get loaded on demand or actually during the bootstrap process?

Any links of references explaining this would be very helpful.

like image 964
Michael Avatar asked Feb 20 '12 19:02

Michael


1 Answers

Your bootstrap class ultimately inherits from Zend_Application_Bootstrap_BootstrapAbstract. The bootstrap() method in this class first searches for class methods prefixed with _init, and runs these. It then looks for resource plugins, which are populated by the 'resources' part of the options array. The options array comes from the configuration passed to Zend Application, which usually comes from application.ini.

Resource plugins map to a class on the file system. So resources.db by default will create an instance of Zend_Application_Resource_Db and run it (which in turns sets up the relevant db stuff). There is a full list of the built in resources here: http://framework.zend.com/manual/en/zend.application.available-resources.html

All your application resources are run during the bootstrap process, unless you've told the bootstrap to init only specific ones.

There is a reasonably detailed overview of how it all fits together in the docs: http://framework.zend.com/manual/en/zend.application.theory-of-operation.html, but it's the kind of thing that you don't really need to know the details of unless your requirements are a little custom.

like image 60
Tim Fountain Avatar answered Nov 13 '22 09:11

Tim Fountain