@@ -11,29 +11,44 @@ tools loaded that you don't in production environments, etc.
1111
1212.. contents ::
1313 :local:
14- :depth: 2
14+ :depth: 3
15+
16+ ************************
17+ The Defined Environments
18+ ************************
19+
20+ By default, CodeIgniter has three environments defined.
21+
22+ - ``production `` for production
23+ - ``development `` for development
24+ - ``testing `` for PHPUnit testing
25+
26+ .. important :: The environment ``testing`` is reserved for PHPUnit testing. It
27+ has special conditions built into the framework at various places to assist
28+ with that. You can't use it for your development.
29+
30+ If you want another environment, e.g., for staging, you can add custom environments.
31+ See `Adding Environments `_.
32+
33+ *******************
34+ Setting Environment
35+ *******************
1536
1637.. _environment-constant :
1738
1839The ENVIRONMENT Constant
1940========================
2041
21- By default, CodeIgniter comes with the ``ENVIRONMENT `` constant set to use
22- the value provided in ``$_SERVER['CI_ENVIRONMENT'] ``, otherwise defaulting to
23- ``production ``. This can be set in several ways depending on your server setup.
24-
25- .. note :: The environment ``testing`` is the special one for PHPUnit testing.
26- It has special conditions built into the framework at various places to assist with that.
27- You can't use it for your development.
42+ To set your environment, CodeIgniter comes with the ``ENVIRONMENT `` constant.
43+ If you set ``$_SERVER['CI_ENVIRONMENT'] ``, the value will be used,
44+ otherwise defaulting to ``production ``.
2845
29- .. note :: You can check the current environment by ``spark env`` command::
30-
31- > php spark env
46+ This can be set in several ways depending on your server setup.
3247
3348.env
3449----
3550
36- The simplest method to set the variable is in your :doc : `.env file </general/configuration >`.
51+ The simplest method to set the variable is in your :ref : `.env file <dotenv-file >`.
3752
3853.. code-block :: ini
3954
@@ -88,8 +103,14 @@ In addition to affecting some basic framework behavior (see the next
88103section), you may use this constant in your own development to
89104differentiate between which environment you are running in.
90105
106+ *******************
107+ Adding Environments
108+ *******************
109+
110+ To add custom environments, you just need to add boot files for them.
111+
91112Boot Files
92- ----------
113+ ==========
93114
94115CodeIgniter requires that a PHP script matching the environment's name is located
95116under **APPPATH/Config/Boot **. These files can contain any customizations that
@@ -102,15 +123,32 @@ a fresh install:
102123* production.php
103124* testing.php
104125
126+ For example, if you want to add ``staging `` environment for staging, all you need
127+ to do is:
128+
129+ 1. copy **APPPATH/Config/Boot/production.php ** to **staging.php **.
130+ 2. customize settings in **staging.php ** if you want.
131+
132+ **********************************
133+ Confirming the Current Environment
134+ **********************************
135+
136+ To confirm the current environment, simply echo the constant ``ENVIRONMENT ``.
137+
138+ You can also check the current environment by ``spark env `` command::
139+
140+ > php spark env
141+
142+ *************************************
105143Effects on Default Framework Behavior
106- =====================================
144+ *************************************
107145
108146There are some places in the CodeIgniter system where the ``ENVIRONMENT ``
109147constant is used. This section describes how default framework behavior
110148is affected.
111149
112150Error Reporting
113- ---------------
151+ ===============
114152
115153Setting the ``ENVIRONMENT `` constant to a value of ``development `` will cause
116154all PHP errors to be rendered to the browser when they occur.
0 commit comments