CodeIgniter Forums

Full Version: Getting your environments just RIGHT!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
http://www.ignitedcoder.com/codeigniter-environments/

Blog post on separating configs between Development and Production environments. Ya just gotta love CI.

Brendan
That is really interesting.

Up to now, as an example, I would add a dev database to the database config file and just set in the file which one to use.


Code:
e.g. $active_group = 'testing';


For me, that is really powerful because I can run tests with the main site offline on a replica of the actual database, knowing for certain no real data is getting damaged.

I would be interested to hear what others think about your post with more knowledge of CI than me. But thinking about it now, when I move a development site to a live server I never copy over the config or system folders anyway, and for live testing your way isn't any use anyway.

Interesting post though, thank you. Coffee time over, I have to actually go and do some real work now :-)

Best wishes,

Paul.
As mentioned in the docs, the Config class will load the global config file first, followed by the ENVIRONMENT file. So, if you  call $this->config->load('email') (or just $this->load->library('email')) when you have the following files:
/application/config/email.php
/application/config/production/email.php

It will load /application/config/email.php first, then load the production file, overwriting any duplicated settings with the production values. So, if your production file only includes the settings which need to change for that environment, it doesn't take much effort to figure out what is changing in each environment.