Config params that reference other config params.

I am rewriting an old website codebase to use Yii. In the old version, the config is a bunch of define statements. Some of these define statements depend on previous ones like.

define('EMAIL_FROM_EMAIL', 'bounce@'.SITE_DOMAIN);

define('EMAIL_REPLY_EMAIL', 'support@'.SITE_DOMAIN);


define('EMAIL_HEADERS', "From: ".EMAIL_FROM."\nContent-Type: text/plain; charset=iso-8859-1\nReturn-Path: ".EMAIL_FROM_EMAIL."\nErrors-To: ".EMAIL_FROM_EMAIL."\nReply-to: ".EMAIL_REPLY_EMAIL);

Most config items I’ve been putting in the main yii config under params, but since it’s just a nested associative array I don’t see how I can chain them like this.

What is the best way to do this kind of thing in Yii?

Maybe in your config file (main.php) before "return array(…"?

In the beginning, do an include()… to include your constants definitions? I think that shall work and using the defined constants in your config array, those that were defined earlier in the included constants file, would be used as needed.

Write your config params array and put them in params.php or within the same file… then just merge them if you are using other params array on your app and then set your application ‘params’:

// both files return an array

$params = array_merge(

		require($root . '/backend/config/params.php'),

		require($root . '/backend/config/params-local.php')


// set 'params'  on your main config.php file

return array(

	// ..

	'params' => $params,