Environment dependent configuration - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Environment dependent configuration (/showthread.php?tid=13872) |
Environment dependent configuration - El Forum - 12-09-2008 [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 Environment dependent configuration - El Forum - 12-09-2008 [eluser]haraldo[/eluser] Try the syntax Code: config_item('environment') Thats what i use in my config files to access other config variables. Environment dependent configuration - El Forum - 12-09-2008 [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. |