From cc7be623caca99c301966eebf29fb6eef6359717 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 31 Mar 2023 11:32:21 +0900 Subject: [PATCH 01/13] docs: improve expression --- user_guide_src/source/general/environments.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index c95041865f54..e0251aff9c0a 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -22,7 +22,7 @@ By default, CodeIgniter comes with the ``ENVIRONMENT`` constant set to use the value provided in ``$_SERVER['CI_ENVIRONMENT']``, otherwise defaulting to ``production``. This can be set in several ways depending on your server setup. -.. note:: The environment ``testing`` is the special one for PHPUnit testing. +.. note:: The environment ``testing`` is reserved for PHPUnit testing. It has special conditions built into the framework at various places to assist with that. You can't use it for your development. From 41de8815a5f6c758a57fd538b1674d5663e9b9df Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 31 Mar 2023 11:36:47 +0900 Subject: [PATCH 02/13] docs: move the sentence --- user_guide_src/source/general/environments.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index e0251aff9c0a..25a34e25c64b 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -20,7 +20,7 @@ The ENVIRONMENT Constant By default, CodeIgniter comes with the ``ENVIRONMENT`` constant set to use the value provided in ``$_SERVER['CI_ENVIRONMENT']``, otherwise defaulting to -``production``. This can be set in several ways depending on your server setup. +``production``. .. note:: The environment ``testing`` is reserved for PHPUnit testing. It has special conditions built into the framework at various places to assist with that. @@ -30,6 +30,8 @@ the value provided in ``$_SERVER['CI_ENVIRONMENT']``, otherwise defaulting to > php spark env +This can be set in several ways depending on your server setup. + .env ---- From 2467bb4ec55e4cb9b277f987b87f080f007c94e0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 31 Mar 2023 11:37:05 +0900 Subject: [PATCH 03/13] docs: improve link --- user_guide_src/source/general/configuration.rst | 2 ++ user_guide_src/source/general/environments.rst | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/general/configuration.rst b/user_guide_src/source/general/configuration.rst index bce8c1d602f5..aefcad81809d 100644 --- a/user_guide_src/source/general/configuration.rst +++ b/user_guide_src/source/general/configuration.rst @@ -63,6 +63,8 @@ One of today's best practices for application setup is to use Environment Variab Environment Variables should also be used for anything private such as passwords, API keys, or other sensitive data. +.. _dotenv-file: + Environment Variables and CodeIgniter ===================================== diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index 25a34e25c64b..e5c01c5ce06e 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -35,7 +35,7 @@ This can be set in several ways depending on your server setup. .env ---- -The simplest method to set the variable is in your :doc:`.env file `. +The simplest method to set the variable is in your :ref:`.env file `. .. code-block:: ini From 96cffc2665bb41ecb8a185ebfd40cad1f98a5547 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 31 Mar 2023 13:08:15 +0900 Subject: [PATCH 04/13] docs: change section title level --- user_guide_src/source/general/environments.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index e5c01c5ce06e..7d7cb460193d 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -104,8 +104,9 @@ a fresh install: * production.php * testing.php +************************************* Effects on Default Framework Behavior -===================================== +************************************* There are some places in the CodeIgniter system where the ``ENVIRONMENT`` constant is used. This section describes how default framework behavior From b0ba1287cc793ab879cc8367734202f4bf4c5581 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 31 Mar 2023 13:09:51 +0900 Subject: [PATCH 05/13] docs: add "The Defined Environments" --- user_guide_src/source/general/environments.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index 7d7cb460193d..ed341e85c3ce 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -13,6 +13,20 @@ tools loaded that you don't in production environments, etc. :local: :depth: 2 +************************ +The Defined Environments +************************ + +By default, CodeIgniter has three environments defined. + +- ``production`` for production +- ``development`` for development +- ``testing`` for PHPUnit testing + +The environment ``testing`` is reserved for PHPUnit testing. It has special +conditions built into the framework at various places to assist with that. +You can't use it for your development. + .. _environment-constant: The ENVIRONMENT Constant From c5739f07ed2fd9ff42e9da24f670a0af78e64130 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 31 Mar 2023 13:10:15 +0900 Subject: [PATCH 06/13] add section title --- user_guide_src/source/general/environments.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index ed341e85c3ce..4926f51804b4 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -27,6 +27,10 @@ The environment ``testing`` is reserved for PHPUnit testing. It has special conditions built into the framework at various places to assist with that. You can't use it for your development. +******************* +Setting Environment +******************* + .. _environment-constant: The ENVIRONMENT Constant From ae6f7278e827743ec5a172d3654b0f9561ab622e Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 31 Mar 2023 13:11:11 +0900 Subject: [PATCH 07/13] docs: add "Adding Environments" --- user_guide_src/source/general/environments.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index 4926f51804b4..66d0e9087b47 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -108,8 +108,14 @@ In addition to affecting some basic framework behavior (see the next section), you may use this constant in your own development to differentiate between which environment you are running in. +******************* +Adding Environments +******************* + +To add custom environments, you just need to add boot files for them. + Boot Files ----------- +========== CodeIgniter requires that a PHP script matching the environment's name is located under **APPPATH/Config/Boot**. These files can contain any customizations that @@ -122,6 +128,12 @@ a fresh install: * production.php * testing.php +For example, if you want to add ``staging`` environment for staging, all you need +to do is: + +1. copy **APPPATH/Config/Boot/production.php** to **staging.php**. +2. customize settings in **staging.php** if you want. + ************************************* Effects on Default Framework Behavior ************************************* From 89bd1710e4758ca8d0b98c295137730c4ac86bd6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 31 Mar 2023 13:12:02 +0900 Subject: [PATCH 08/13] docs: add "Confirming the Current Environment" --- user_guide_src/source/general/environments.rst | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index 66d0e9087b47..36615f64153d 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -44,10 +44,6 @@ the value provided in ``$_SERVER['CI_ENVIRONMENT']``, otherwise defaulting to It has special conditions built into the framework at various places to assist with that. You can't use it for your development. -.. note:: You can check the current environment by ``spark env`` command:: - - > php spark env - This can be set in several ways depending on your server setup. .env @@ -134,6 +130,16 @@ to do is: 1. copy **APPPATH/Config/Boot/production.php** to **staging.php**. 2. customize settings in **staging.php** if you want. +********************************** +Confirming the Current Environment +********************************** + +To confirm the current environment, simply echo the constant ``ENVIRONMENT``. + +You can also check the current environment by ``spark env`` command:: + + > php spark env + ************************************* Effects on Default Framework Behavior ************************************* From 98fd9e999b91861bcbd4d1aa130b4607abc98269 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 31 Mar 2023 13:13:05 +0900 Subject: [PATCH 09/13] docs: delete descriptions that are no longer needed --- user_guide_src/source/general/environments.rst | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index 36615f64153d..b466d92f7f2c 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -36,13 +36,9 @@ Setting Environment The ENVIRONMENT Constant ======================== -By default, CodeIgniter comes with the ``ENVIRONMENT`` constant set to use -the value provided in ``$_SERVER['CI_ENVIRONMENT']``, otherwise defaulting to -``production``. - -.. note:: The environment ``testing`` is reserved for PHPUnit testing. - It has special conditions built into the framework at various places to assist with that. - You can't use it for your development. +To set your environment, CodeIgniter comes with the ``ENVIRONMENT`` constant. +If you set ``$_SERVER['CI_ENVIRONMENT']``, the value will be used, +otherwise defaulting to ``production``. This can be set in several ways depending on your server setup. From cbb844094d78741dfe8f5354f04fb8f628df79e4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 31 Mar 2023 13:19:19 +0900 Subject: [PATCH 10/13] docs: add sentence --- user_guide_src/source/general/environments.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index b466d92f7f2c..377f73820577 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -27,6 +27,9 @@ The environment ``testing`` is reserved for PHPUnit testing. It has special conditions built into the framework at various places to assist with that. You can't use it for your development. +If you want another environment, e.g., for staging, you can add custom environments. +See `Adding Environments`_. + ******************* Setting Environment ******************* From 4afe53acf337d301a2be83ace9a7456f73d40587 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 31 Mar 2023 13:24:47 +0900 Subject: [PATCH 11/13] docs: make note for testing --- user_guide_src/source/general/environments.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index 377f73820577..5557c8bc8824 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -23,9 +23,9 @@ By default, CodeIgniter has three environments defined. - ``development`` for development - ``testing`` for PHPUnit testing -The environment ``testing`` is reserved for PHPUnit testing. It has special -conditions built into the framework at various places to assist with that. -You can't use it for your development. +.. important:: The environment ``testing`` is reserved for PHPUnit testing. It + has special conditions built into the framework at various places to assist + with that. You can't use it for your development. If you want another environment, e.g., for staging, you can add custom environments. See `Adding Environments`_. From 6a4dede220f13ca37d46ca570d7722a968226bcb Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 31 Mar 2023 17:11:28 +0900 Subject: [PATCH 12/13] docs: fix section title level --- user_guide_src/source/general/environments.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index 5557c8bc8824..54a77da23b99 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -148,7 +148,7 @@ constant is used. This section describes how default framework behavior is affected. Error Reporting ---------------- +=============== Setting the ``ENVIRONMENT`` constant to a value of ``development`` will cause all PHP errors to be rendered to the browser when they occur. From cf2880b4d79182bc3c9dd1bd1ae5d1667343b323 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 4 Apr 2023 10:24:52 +0900 Subject: [PATCH 13/13] docs: make TOC depth 3 --- user_guide_src/source/general/environments.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index 54a77da23b99..667a5bd11e46 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -11,7 +11,7 @@ tools loaded that you don't in production environments, etc. .. contents:: :local: - :depth: 2 + :depth: 3 ************************ The Defined Environments