From e8f5890e4b7eb52ed4d905a225c3bf985f397439 Mon Sep 17 00:00:00 2001 From: katzgrau Date: Thu, 10 Mar 2011 10:24:29 -0500 Subject: Added full docs for new ENVIRONMENT constant. --- user_guide/libraries/config.html | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'user_guide/libraries/config.html') diff --git a/user_guide/libraries/config.html b/user_guide/libraries/config.html index 66b8426d9..af7bcfe61 100644 --- a/user_guide/libraries/config.html +++ b/user_guide/libraries/config.html @@ -153,21 +153,39 @@ $site_name = $blog_config['site_name'];

Environments

-

You can set the environment of you application and load config items depending on the current environment. It also disables PHP from displaying errors in environments other than development. To set your environment, open index.php, located at the root and change the ENVIRONMENT constant. By default, there is support for a development, test and production environment.

- - -define('ENVIRONMENT', 'development'); - +

+ You may load different configuration files depending on the current environment. + The ENVIRONMENT constant is defined in index.php, and is described + in detail in the Handling Environments + section. +

+ +

+ 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:

+ +
    +
  1. Create the directory application/config/production/
  2. +
  3. Copy your existing config.php into the above directory
  4. +
  5. Edit application/config/production/config.php so it contains your production settings
  6. +
+ +

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

-

To make a config file environment-aware, copy the file from application/config/ to application/config/development/, depending on the environment the config file belongs to. You can place the following configuration files in environment folders:

+

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

-

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

+

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.

Helper Functions

-- cgit v1.2.3-24-g4f1b