From d1c21a47efdb9083d232f1f11bf3eeff8d308dd8 Mon Sep 17 00:00:00 2001 From: katzgrau Date: Wed, 9 Mar 2011 23:22:45 -0500 Subject: Added changelog note for multi-environment support for configs --- user_guide/libraries/config.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'user_guide/libraries/config.html') diff --git a/user_guide/libraries/config.html b/user_guide/libraries/config.html index 98b6052a9..66b8426d9 100644 --- a/user_guide/libraries/config.html +++ b/user_guide/libraries/config.html @@ -150,6 +150,7 @@ $site_name = $blog_config['site_name'];

Where item_name is the $config array index you want to change, and item_value is its value.

+

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.

@@ -195,4 +196,4 @@ Next Topic:  Database Class - \ No newline at end of file + -- cgit v1.2.3-24-g4f1b 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