Dynamically distinguish between development, testing and production servers in CodeIgniter

You can Configure the CodeIgniter to Dynamically distinguish between development, test and production servers, It’s Better to keep your Development, testing, and production Config options in different files.Don’t Mix your Config Options, NO more sudden crashes after an un-careful deployment, to avoid crashes set your ENVIRONMENT variable Dynamically.

In Codeigniter, you can load different Configuration files depending on the current environment.ENVIRONMENT Constant is defined in index.php.

To create an environment-specific configuration file, create or copy a configuration file in application/config/{ENVIRONMENT}/{FILENAME}.php

For example, to create a production-only config.php, you would:

Create the directory application/config/production/
Copy your existing config.php into the above directory
Edit application/config/production/config.php so it contains your production settings

When you set the ENVIRONMENT constant to ‘production’, the settings for your new production-only config.php will be loaded.

You can place the following configuration files in environment-specific folders:

Default CodeIgniter configuration files
Your own custom configuration files

Note: CodeIgniter always tries to load the configuration files for the current environment first. If the file does not exist, the global config file (i.e., the one in application/config/) is loaded. This means you are not obligated to place all of your configuration files in an environment folder − only the files that change per environment.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.