Properties defined for production do not need to get repeated in the sections below (testing and development), only add them to testing or development if their value is different then the production value.
A section will inherit properties and their values from another section if you you add a semicolon after the section name followed by the name of the section it should inherit from. This means that in my example testing will inherit the properties and corresponding values from production and development will inherit the properties and values from testing.
[production] ; the values used in production which may be different then the ones in testing or development [testing : production] ; testing specific properties and values [development : testing] ; development specific properties and values
In the php settings part we disable error messages in production mode but enable them for the other environments. We also define a default timezone "Europe/Luxembourg" in the php settings part. Change this to your timezone values.
[production] ; PHP SETTINGS phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 [testing : production] ; PHP SETTINGS phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 [development : testing] ; PHP SETTINGS phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1
The library path
The second part sets the path to our library folder.
includePaths.library = APPLICATION_PATH "/../library"
Bootstrap path and name
The fourth part sets the path and name of our bootstrap file.
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
The fifth part lists the modules we will add to our application, I will use those values in different parts of my application, more about this in one of my next tutorials.
resources.modules = Homepage, Admin, Users, Articles
Let's configure the frontcontroller of our app. The frontcontroller configuration is very important. Important information about the frontcontroller can be found in the official documentation. For now you just need to know that the frontcontroller is a singleton. So every time that you access the request or response of your app, which both are in the container of the frontcontroller, you will always get the same request and response object. This is for example important so that you don't end up with multiple versions of a response object. The frontcontroller implements the frontcontroller pattern, is the heart of our MVC app.
In the sixth part we set some values for the frontcontroller. We will put our modules in a folder called "modules" and we will use homepage as name for our main (default) module. The name of the default controller will be "index" and the default action will have the name "index".
resources.frontcontroller.moduledirectory = APPLICATION_PATH "/modules" resources.frontcontroller.defaultmodule = "homepage" resources.frontController.defaultControllerName = "index" resources.frontController.defaultAction = "index"
The next value tells zend framework to use a prefix for the default module. By default zend framework allows you to ommit the prefix for the files in the default module folder. I set this value to true because there are so much things you have to explain to somebody that is new to zend framework, that's why i prefer not having to explain which module is the default one and that only for this module you should not use a prefix.
resources.frontcontroller.params.prefixDefaultModule = true
I set throw exceptions to false, because i dont want exceptions to popup as soon as they get thrown. If you set throwExceptions to true the try / catch in our index file will handle the error. I want to use the error controller that we will build during one of the next tutorials.
resources.frontcontroller.throwexceptions = false
In the last key / value pair we set the application environment we have set in the htaccess and defined in the index.php so that zend framework can pass it to the frontcontroller.
resources.frontController.env = APPLICATION_ENVIRONMENT
The last part is for website "myapp" specific values, right now we only need one value, the default title for the title tag in our html pages.
; MY APP website.title = myapp
Those are all the values we want to use for our production environment, our testing and development environments will inherit those values, but we will also override some of them.
We will add lots more key / value pairs later in other tutorials but right now its already more then enough to get started.
Here is the full configuration file:
[production] ; PHP SETTINGS phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 phpSettings.date.timezone = "Europe/Luxembourg" ; ZEND LIBRARY PATH includePaths.library = APPLICATION_PATH "/../library" ; BOOTSTRAP bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" ; MODULES SETUP resources.modules = Homepage, Admin, Users, Articles ; Layout resources.layout.layoutpath = APPLICATION_PATH "/layouts/scripts" ; Application resources.frontcontroller.moduledirectory = APPLICATION_PATH "/modules" resources.frontcontroller.defaultmodule = "homepage" resources.frontController.defaultControllerName = "index" resources.frontController.defaultAction = "index" resources.frontcontroller.params.prefixDefaultModule = true resources.frontcontroller.throwexceptions = false resources.frontController.env = APPLICATION_ENVIRONMENT ; MY APP website.title = myapp [testing : production] ; PHP SETTINGS phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 [development : testing] ; PHP SETTINGS phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1
For more information about the Zend Framework configuration files check out this chapter of the Zend Framework configuration documentation.