CodeIgniter Forums
Getting your environments just RIGHT! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Getting your environments just RIGHT! (/showthread.php?tid=62764)



Getting your environments just RIGHT! - BrendanRehman - 08-23-2015

http://www.ignitedcoder.com/codeigniter-environments/

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

Brendan


RE: Getting your environments just RIGHT! - PaulD - 09-01-2015

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.


RE: Getting your environments just RIGHT! - mwhitney - 09-01-2015

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.