2.3. Configuration

2.3. Configuration

A wide variety of configuration formats can be supported through the use of Zend_Config classes. Zym_App loads configs of different formats by detecting their extension and using it to form a class like Zend_Config_Xml for "bootstrap.xml". You may also specify your own classname to be appended instead of guessing from the file extension.

Example 2.4. Config file skeleton

Config skeleton showing all default environments

<?xml version="1.0" encoding="UTF-8"?>
<!-- 
Tags below <bootstrap> are configuration for each environment set in Zym_App.
 
Each section below extends the <default> config section if it has the 
"extends" attribute. Adding a tag in <production> would override the value
set from <default> for the production environment.
-->
<bootstrap>
    <!--
    Production environment overrides
    -->
    <production extends="default"></production>
 
    <!--
    Test environment overrides
    -->
    <test extends="default"></test>
 
    <!--
    Development environment overrides
    -->
    <development extends="default"></development>
 
    <!--
    Default environment config
 
    This environment is the default for all environments that extend it.
    -->
    <default></default>
</bootstrap>

[Important] Important

The general format of every config file must contain a Zend_Config "default" section and a section for every other environment you plan to use. This is a limitation of Zend_Config at the moment because we cannot distinguish between its exceptions.

[Important] Empty config values

Do not leave config keys with empty values because it will override the default value. If the current element has childs in the default, it will remove all those default childs causing an error.

Example 2.5. An example of an empty config value

Having something like below will remove all childs, so if you do not need to set something, don't leave it empty.

<path></path>

Example 2.6. Simple bootstrap config (bootstrap.xml)

This is a simple bootstrap configuration file loading only several resources. The minimum amount really required to bootstrap the ZF mvc is just the controller resource.

<?xml version="1.0" encoding="UTF-8"?>
<!-- 
Tags below <bootstrap> are configuration for each environment set in Zym_App.
 
Each section below extends the <default> config section if it has the 
"extends" attribute. Adding a tag in <production> would override the value
set from <default> for the production environment.
-->
<bootstrap>
    <!--
    Production environment overrides
    -->
    <production extends="default"></production>
 
    <!--
    Test environment overrides
    -->
    <test extends="default"></test>
 
    <!--
    Development environment overrides
    -->
    <development extends="default"></development>
 
    <!--
    Default environment config
 
    This environment is the default for all environments that extend it.
    -->
    <default>
        <!-- Unique application id -->
        <name>Zym</name>
 
        <!--
        Resources to bootstrap
 
        Resources are loaded generally in FIFO order except for exceptions
        of priorities placed on some resources.
        -->
        <resource>
            <autoload />
            <session />
            <view />
            <layout />
            <controller />
        </resource>
    </default>
</bootstrap>

2.3.1. Bootstrap configuration options

Table 2.1. Zym_App Configuration Options

Key Default Description
name
default Zym
A unique application name/id
home
default ../
The base project directory
namespace
default array('Zym' => 'Zym_App_Resource')
Namespaces to use for loading resources. They should be in the form of key/value as the key will be used later for overriding the namespace of a resource to load. It should be in LIFO order.
path
default array()
Path declarations for Zym_App Can significantly effect directory structure of an app from changing these values. All paths are relative to "home" unless "/" root is specified. Other config keys and paths can be specified here that are not listed. They can be accessed using Zym_App::getInstance()->getPath('pathKey');
path.app
default app
Path of "app" directory containing application related files (modules, layouts).
path.config
default config
Path of "config" directory containing configs.
path.data
default data
Path of "data" directory contain application data.
path.temp
default temp
Path of "temp" directory for temporary files.
cache
default array()
Caching configuration
cache.enabled
default false
production true
(boolean) Whether Zym_App should use caching. True in production environment.
cache.prefix
default %__
Prefix used for cache id's. "%s" contains the value of the "name" config. This prefix string must conform to Zend_Config's specifications.
default_resource
default array()
Default configuration for dispatching of resources. Refer to the "resource" item config for more details. Changing an item here will change the default for each "resource" item config.
default_resource.disabled
default false
(boolean) Determines whether the resource is dispatched
default_resource.config
default %s.xml
(string|array) Where to load configuration from. This path is relative to path.config unless path is from root ("/foo/bar"). Loads from "config/foo.xml" by default. "%s" is the resource name.
default_resource.environment
default  
Allows you to override the environment used to configure and dispatch resources.
default_resource.namespace
default  
Allows you to override the namespace used in dispatching resources. Refer to "namespace" key.
default_resource.priority
default  
Override resources' dispatching priority
resource
default array()
Resources to dispatch. The key is the resource. (eg. resource.controller) Refer to default_resource for each item's configuration options and defaults.
resource.{resource}.disabled
default refer to default_resource.disabled
Disables the resource from dispatching. Useful for quick debugging.
resource.{resource}.config
default refer to default_resource.config
(string|array) Where to load configuration from. This path is relative to path.config unless path is from root ("/foo/bar"). Loads from "config/foo.xml" by default. "%s" is the resource name. If an array is provided instead, it will be used for a resource's configuration. This allows you to have a single config file for the whole application.
resource.{resource}.environment
default refer to default_resource.environment
Allows you to override the environment used to configure and dispatch the current resource.
resource.{resource}.namespace
default refer to default_resource.namespace
Allows you to override the namespace used in dispatching the resource. Refer to "namespace" key.
resource.{resource}.priority
default refer to default_resource.priority
(int) Higher priority is 10, lower is 50 and default is 25 Override resource dispatching priority
registry
default Zym_App_Registry
The internal registry class to use. It should be a child of Zym_App_Registry.