[eluser]XMadMax[/eluser]
I have the same source code for all environments, this allows to be more secure to upload code to prod servers.
In index.php:
Code:
switch ($_SERVER['HTTP_HOST'])
{
case 'www.myserver.com':
define('ENVIRONMENT', 'production');
break;
case 'www.myserver.local':
define('ENVIRONMENT', 'development');
break;
case 'www.myserver.myintegrationserver.com':
define('ENVIRONMENT', 'integration');
break;
}
In your config directory, create this folders:
Code:
development
production
integration
In your config/database.php file, add this line at the end:
Code:
include(strtolower(ENVIRONMENT).'/env_database.php');
The file inside development folder MUST to be different name. If you have ENVIRONMENT defined, Codeigniter tries to load it instead of the base one. The method explained allow you to extend config, firts is loaded the base condig, and overloaded by ypur specific one.
Inside env_database.php:
Code:
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'root';
$db['default']['database'] = 'mylocaldatabase';
$db['default']['dbdriver'] = 'mysqli';
All $db default values will be loaded from /config/database.php, in your env_database.php file, you only put the values overloaded.