@@ -6,19 +6,41 @@ Developers often desire different system behavior depending on whether
66an application is running in a development or production environment.
77For example, verbose error output is something that would be useful
88while 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
1112The ENVIRONMENT Constant
1213========================
1314
1415By default, CodeIgniter comes with the environment constant set to use
1516the 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
2021This server variable can be set in your ``.htaccess `` file, or Apache
2122config 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+
2244Alternative methods are available for nginx and other servers, or you can
2345remove 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
2749section), you may use this constant in your own development to
2850differentiate 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+
3066Effects On Default Framework Behavior
3167=====================================
3268
0 commit comments