Skip to content

Commit 4797e82

Browse files
committed
Documenting new environment change
1 parent dcad5c4 commit 4797e82

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

public/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
}
3232
else
3333
{
34-
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
34+
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production');
3535
}
3636

3737
/*

user_guide_src/source/general/environments.rst

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,41 @@ Developers often desire different system behavior depending on whether
66
an application is running in a development or production environment.
77
For example, verbose error output is something that would be useful
88
while developing an application, but it may also pose a security issue
9-
when "live".
9+
when "live". In development environments, you might want additional
10+
tools loaded that you don't in production environments, etc.
1011

1112
The ENVIRONMENT Constant
1213
========================
1314

1415
By default, CodeIgniter comes with the environment constant set to use
1516
the value provided in ``$_SERVER['CI_ENV']``, otherwise defaulting to
16-
'development'. At the top of index.php, you will see::
17+
'production'. At the top of index.php, you will see::
1718

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

2021
This server variable can be set in your ``.htaccess`` file, or Apache
2122
config using `SetEnv <https://httpd.apache.org/docs/2.2/mod/mod_env.html#setenv>`_.
23+
::
24+
25+
SetEnv CI_ENV development
26+
27+
Under nginx, you must pass the environment variable through the ``fastcgi_params``
28+
in order for it to show up under the `$_SERVER` variable. This allows it to work on the
29+
virtual-host level, instead of using `env` to set it for the entire server, though that
30+
would work fine on a dedicated server. You would then modify your server config to something
31+
like::
32+
33+
server {
34+
server_name localhost;
35+
include conf/defaults.conf;
36+
root /var/www;
37+
38+
location ~* "\.php$" {
39+
fastcgi_param CI_ENV "production";
40+
include conf/fastcgi-php.conf;
41+
}
42+
}
43+
2244
Alternative methods are available for nginx and other servers, or you can
2345
remove this logic entirely and set the constant based on the server's IP address
2446
(for instance).
@@ -27,6 +49,20 @@ In addition to affecting some basic framework behavior (see the next
2749
section), you may use this constant in your own development to
2850
differentiate between which environment you are running in.
2951

52+
Boot Files
53+
----------
54+
55+
CodeIgniter requires that a PHP script matching the environment's name is located
56+
under **APPPATH/Config/Boot**. These files can contain any customizations that
57+
you would like to make for your environment, whether it's updating the error display
58+
settings, loading addtional developer tools, or anything else. These are
59+
automatically loaded by the system. The following files are already created in
60+
a fresh install:
61+
62+
* development.php
63+
* production.php
64+
* testing.php
65+
3066
Effects On Default Framework Behavior
3167
=====================================
3268

0 commit comments

Comments
 (0)