Configurations and environments

I find RAILS environment system very useful, and I have been using my own implementation on Yii:

[list=1][]I have a base configuration for all the environments.[]Then, I merge it with the specific environment configuration.[*]Finally, I merge it with the local configuration.[/list]So this is my base config folder for all my projects:







I would like to see Yii providing an easy way of doing this without the dirty CMap::mergeArray() calls inside the config files. This feature should not be enabled by default because it is less flexible.

I usually define the environment on the index.php / yiic.php

Optionally: For very complex applications I use folder-based configurations with a bootstrap script that merges all the files of the folder in a single array, saving it in the cache.


I’m developing this way as well but using CMap::mergeArray() doesn’t look dirty to me.


Then I propose adding this environment configuration by default to the advanced config I proposed here

Another thing I often stumbled upon with configurations is the problem that I have to set values, which rely on a Yii method, eg. Yii::app()->baseUrl, this is often needed for extensions (e.g. CSS or JavaScript includes). If I do not publish them via assetManager.

'extensionXY' => array(

  'scriptUrl' => Yii::app()->baseUrl.'/path/to/javascript.js'


I think that application properties should be used after the config definition. For example:


'extensionXY' => array(

    'scriptUrl' => 'path/to/javascript.js'



public function init() {

    if($this->scriptUrl is a relative path)

     	$this->scriptUrl = Yii::app()->baseUrl.'/'.$this->scriptUrl;



I’m also using CMap to merge configs and is fine.

@schmunk , in 2.0, aliases will be more flexible allowing this kinda of usage

I’m using this extension. It does a fantastic job managing my configuration files.

Also for URLs not only local paths?