This is going to be a quick post… actually all my codeigniter related posts will be quick hints and tips to make your codeigniter development easier.
This particular tip relates to productions vs development environments. Did you know that seperating production/development environments it CI is really easy?
- Inside your application/config folder simple add 2 new folders as follows
- Grab a copy of autoload.php, database.php and email.php if you have a email config file and place them into each of the folders /production & /development respectively.
- Time to edit your index.php file in the root folder of your site.
Find the following line of code in your index.php file:
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
$env = $_SERVER['HTTP_HOST'] == 'yourlocaldevdomain.dev' ? 'development' : 'production';
Voila, thats it – CI will now use either the production or development folders based on your host domain.