Skip to content

Commit

Permalink
Added support for $_SERVER['CI_ENV'] in index.php
Browse files Browse the repository at this point in the history
Remember this is entirely optional, nothing will change if you do not which to use Multiple Environments just like right now. If you DO set CI_ENV you can manipulate the switch that controls error reporting, etc, so set it to "production" on your live site to hide errors from users. If you don't require this logic you can remove it, or change it entirely to check HTTP_HOST for environment subdomains, or check IP address, etc.
  • Loading branch information
Phil Sturgeon committed Jun 3, 2012
1 parent 2d8707f commit dda21f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*
* NOTE: If you change these, also change the error_reporting() code below
*/
define('ENVIRONMENT', 'development');
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Release Date: Not Released
- General Changes

- PHP 5.1.6 is no longer supported. CodeIgniter now requires PHP 5.2.4.
- ``$_SERVER['CI_ENV']`` can now be set to control the ``ENVIRONMENT`` constant.
- Added an optional backtrace to php-error template.
- Added Android to the list of user agents.
- Added Windows 7, Android, Blackberry and iOS to the list of user platforms.
Expand Down
10 changes: 8 additions & 2 deletions user_guide_src/source/general/environments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ when "live".
The ENVIRONMENT Constant
========================

By default, CodeIgniter comes with the environment constant set to
By default, CodeIgniter comes with the environment constant set to use
the value provided in ``$_SERVER['CI_ENV']``, otherwise defaults to
'development'. At the top of index.php, you will see::

define('ENVIRONMENT', 'development');
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');

This server variable can be set in your .htaccess file, or Apache
config using `SetEnv <https://httpd.apache.org/docs/2.2/mod/mod_env.html#setenv>`_.
Alternative methods are available for nginx and other servers, or you can
remove this logic entirely and set the constant based on the HTTP_HOST or IP.

In addition to affecting some basic framework behavior (see the next
section), you may use this constant in your own development to
Expand Down

0 comments on commit dda21f6

Please sign in to comment.