Codeigniter how to conditionally load config files? - 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: Codeigniter how to conditionally load config files? (/showthread.php?tid=20008) |
Codeigniter how to conditionally load config files? - El Forum - 06-25-2009 [eluser]sabya[/eluser] I am using CodeIgniter to write a application. I need to create something like this: - I will have: - * my_config.php * config_production.php * config_development.php Now, my_config.php will be autoloaded. From there, if it is production server config_production.php will be loaded. Else config_development.php will be loaded. how should I do this? I tried doing like this in my_config.php: - Code: <?php It is not working because, the "$this->config" is not initialized yet. How can I achieve this? Codeigniter how to conditionally load config files? - El Forum - 06-25-2009 [eluser]Dam1an[/eluser] Can you not just include the file with normal PHP? Code: include APPPATH.'config/config_development.php'; Codeigniter how to conditionally load config files? - El Forum - 06-25-2009 [eluser]Phil Sturgeon[/eluser] That would work as long as you made the include in a config file that WAS being included correctly. Otherwise the config items wont accessable via $this->config->item(). Take a look at How to Support multiple production environments in CodeIgniter which should help you with some of this. Codeigniter how to conditionally load config files? - El Forum - 06-25-2009 [eluser]Dam1an[/eluser] Phil, I think your link is a bit screwed up, it's Code: http://philsturgeon.co.uk/news/2009/06/news/2009/01/How-to-Support-multiple-production-environments-in-CodeIgniter.html Which seems wrong, not to mention the fact it just goes to the news page, instead of said article I think all that publicity of being mentioned on PHP Developer has gone to your head Codeigniter how to conditionally load config files? - El Forum - 06-25-2009 [eluser]Phil Sturgeon[/eluser] That'll teach me to copy links directly from the address bar suggestions! Codeigniter how to conditionally load config files? - El Forum - 06-25-2009 [eluser]sabya[/eluser] Thanks guys! I got it working, like this: - Code: $ci = & get_instance(); |