Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZF2: how to implement different configs for production, staging etc?

In the sceleton application that I've downloaded from github there is a file module/Application/config/module.config.php

return array(
    'layout'                => 'layout/layout.phtml',
    'display_exceptions'    => true,
    'di'                    => array(
        'instance' => array(
        'alias' => array(....

this file is used in module/Application/module.php:

public function getConfig()
{
    return include __DIR__ . '/config/module.config.php';
}

How to create 3 different configs depending on domain (production, staging, development)? It seems in ZF1 env vars has been used, but I don't know how to do that in zf2 module. Thank you!

like image 329
varan Avatar asked Mar 24 '12 07:03

varan


1 Answers

Create a file called development.config.php in application/config/autoload and this will be loaded after all the modules' config files have been loaded. As a result, you can override anything the merged configuration by adding the relevant keys to this file.

The name of the file loaded is {APPLICATION_ENV}.config.php, so you can create production.config.php, etc.

Note that you may have to change the glob in index.php as it's unclear if the Skeleton application will work out of the box with APPLICATION_ENV or not at this stage of the development of ZF2 (early April 2012).

like image 122
Rob Allen Avatar answered Sep 26 '22 23:09

Rob Allen