Codeigniter how to conditionally load config files? |
[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?
[eluser]Dam1an[/eluser]
Can you not just include the file with normal PHP? Code: include APPPATH.'config/config_development.php';
[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.
[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
[eluser]Phil Sturgeon[/eluser]
That'll teach me to copy links directly from the address bar suggestions!
[eluser]sabya[/eluser]
Thanks guys! I got it working, like this: - Code: $ci = & get_instance(); |
Welcome Guest, Not a member yet? Register Sign In |