PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Quick Start

The following is a YAML version of a standard application configuration.

production:
  phpSettings:
    display_startup_errors: false
    display_errors: false
  includePaths:
    library: APPLICATION_PATH/../library
  bootstrap:
    path: APPLICATION_PATH/Bootstrap.php
    class: "Bootstrap"
  appnamespace: "Application"
  resources:
    frontController:
      controllerDirectory: APPLICATION_PATH/controllers
      moduleDirectory: APPLICATION_PATH/modules
      params:
        displayExceptions: false
    modules:
    db:
      adapter: "pdo_sqlite"
      params:
        dbname: APPLICATION_PATH/../data/db/application.db
    layout:
      layoutPath: APPLICATION_PATH/layouts/scripts/

staging:
  _extends: production

testing:
  _extends: production
  phpSettings:
    display_startup_errors: true
    display_errors: true

development:
  _extends: production
  phpSettings:
    display_startup_errors: true
    display_errors: true
  resources:
    frontController:
      params:
        displayExceptions: true

To utilize it, you simply instantiate Zend_Config_Yaml, pointing it to the location of this file and indicating the section of the file to load. By default, constant names found in values will be substituted with their appropriate values.

<?php
$config 
= new Zend_Config_Yaml(
    
APPLICATION_PATH '/configs/application.yaml',
    
APPLICATION_ENV
);

Once instantiated, you use it as you would any other configuration object.

<?php
$db 
Zend_Db::factory($config->resources->db);

Zend Framework