Bootstrapping the Application: Configuration File Overview
Sunday, September 20, 2009

The configuration file can either be in INI file or XML format. Personally, I have always used INI files with the Zend Framework, so that is the format that will be used in the sample application.

The configuration file is divided into sections; this gives the following overall structure:

[production]
; Settings used in a production environment
[staging : production]
; Settings used in a staging environment
[testing : production]
; Settings used in a testing environment
[development : production]
; Settings used in a development environment

The basic notation used to denote the start of a section is [ name ]; if a section inherits settings from another section, the notation used is [ name : parent ]. Note that when a section inherits settings, these will be overridden if redeclared within the section.

The majority of the settings are contained in the production section; the settings that are redefined in the other settings are concerned with error reporting. In production mode, on screen error reporting is suppressed for security reasons, as error messages may give away crucial information about the system configuration:

[ production ]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0

On the other hand, on screen errors are helpful in development and testing environments:

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
 
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

As the staging environment is meant to be closer to a production environment, the error reporting settings are not overridden there.

All the remaining settings we shall examine are in the production section and apply to all environments.

The name and location of the bootstrap is specified in the configuration file:

bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"

This class is created and run automatically by Zend_Application. I shall look at its implementation later.

In my next post, I shall look at the system of resources, in particular how they are declared in the configuration file.

Posted by James at 4:06 pm   0 comments

Leave a Reply