I need to create something similar to the following within my CodeIgniter project:
my_config.phpconfig_production.phpconfig_development.php
Now, my_config.php will be autoloaded. From there, if it is a production server, config_production.php will be loaded; else config_development.php will be loaded.
How should I go about executing this?
I’ve tried doing the following in my_config.php:
<?php
if(gethostbyaddr ("127.0.0.1") == 'hello.sabya'){
$this->config->load('config_production');
} else {
$this->config->load('config_development');
}
?>
It is not working as $this->config is not initialized. How can I achieve this?
Two options: You can try referencing the object with
$CIinstead of$this:…which is the correct way to reference the CI object from the outside.
Or secondly, you could switch configs from within your config.php file:
…etc. Load all the differences between the two
if/elseblocks.