You don't need to duplicate your application for each environement. Codeigniter can handle multiple configurations. You just need to set one folder per environment.
Let's suppose the following organization :
Root/
-Application
-System
-Assets
-css
-js
-images
-index.php
We will have 3 environments: Dev/Testing/Production.
We know that our application will have a different base_url and database conf depending on the environment. It means that we will need to modify config.php and database.php each time we will move our app from an env to an other.
CodeIgniter provides us an easy way to do that :
http://www.codeigniter.com/user_guide/general/environments.html
http://www.codeigniter.com/user_guide/libraries/config.html#environments
We just need to set 3 folders inside application/config
-application
-config
- development
- testing
- production
Inside those new folders, just place the config files which will be different on each environement. In our case, config.php and database.php
-application
-config
- development
-config.php
-database.php
- testing
-config.php
-database.php
- production
-config.php
-database.php
- autoload.php
- ...
Finally, in the root index.php just have to modify the following line to tell CI in which environement it is :
define('ENVIRONMENT', 'development'); //for dev env
define('ENVIRONMENT', 'testing'); //for testing env
define('ENVIRONMENT', 'production'); //for prod env
development/testing/production are defaults environements in CI but you can create your own just by creating your folders in application/config and modifying the switch in the root index.php :
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
break;
case 'server':
error_reporting(E_ALL);
break;
case 'testing':
case 'production':
error_reporting(0);
break;
/*CUSTOM ENV :*/
case 'custom_env':
error_reporting(E_ALL);
break;
default:
exit('The application environment is not set correctly.');
}