Welcome Guest, Not a member yet? Register   Sign In
Environment dependent configuration
#1

[eluser]thomasz[/eluser]
I have some configuration files that are different from different environments (Dev, Test, Production). I am trying to figure out the best way to manage this without having to track multiple versions of the config files.

What I tried was to create an environment value in the main config.php. Such as this:
$config['environment'] = 'DEV'; //valid values are DEV, TEST, PROD

Then in an application config file myapp_config.php I could check the evironment:
if ($config['environment'] == 'PROD') {
$config['value'] = 'value 1';
else {
$config['value'] = 'value 2';
}

However this blew up on the "if $config['environment']" since environment is not defined. Does anyone know either:
a) how best to solve the problem of environment dependent variables or
b) how to reference a config within another config

Thanks
Thomas
#2

[eluser]haraldo[/eluser]
Try the syntax
Code:
config_item('environment')
.

Thats what i use in my config files to access other config variables.
#3

[eluser]thomasz[/eluser]
[quote author="haraldo" date="1228871238"]Try the syntax
Code:
config_item('environment')
.

Thats what i use in my config files to access other config variables.[/quote]

Oh dear god. I feel dumb. Makes total sense, just had my mind in the wrong place. That worked, thanks.




Theme © iAndrew 2016 - Forum software by © MyBB