CodeIgniter development site – on live environment

We recently had to set up a development site for an existing CodeIgniter site, and we wanted to do this effortless. Ideal would obviously be to have a separate virtual domain or a separate box but hey, “ideal” isn’t always ideal, heh.

By applying the same principle as in our previous WordPress article on the same topic, this is done in well under 5 minutes. Upload the same /dev folder as in the WordPress case, and make the following modification in the main CodeIgniter index.php file.

Change this:

$system_folder = "system";

to:

if(isset($_COOKIE["dev"])){
	$system_folder = "sysdev";
}else{
	$system_folder = "system";
}

Then copy the /system directory to /sysdev – and that will be your new development docroot. Once you’re ready to release your next version, either copy each file from /sysdev to /system – or simply change the name of /system to /system-OLD and /sysdev to /system.

One thought on “CodeIgniter development site – on live environment

  1. Great tip!
    Instead of using a cookie I’m using a environment variable. Similiar to Ruby on Rails approach to this problem. See examples below.

    apache: SetENV ENVIRONMENT production
    nginx: fastcgi_param ENVIRONMENT production

Comments are closed.