Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Apr 5, 2023
2 parents 7c76890 + d5b28fd commit fea41d8
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 38 deletions.
24 changes: 12 additions & 12 deletions system/HTTP/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ public function getDefaultLocale(): string
*
* @param array|string|null $index
* @param int|null $filter Filter constant
* @param mixed $flags
* @param array|int|null $flags
*
* @return array|bool|float|int|stdClass|string|null
*/
Expand Down Expand Up @@ -719,7 +719,7 @@ public function getRawInput()
* @param int|null $filter Filter Constant
* @param array|int|null $flags Option
*
* @return mixed
* @return array|bool|float|int|object|string|null
*/
public function getRawInputVar($index = null, ?int $filter = null, $flags = null)
{
Expand Down Expand Up @@ -771,9 +771,9 @@ public function getRawInputVar($index = null, ?int $filter = null, $flags = null
*
* @param array|string|null $index Index for item to fetch from $_GET.
* @param int|null $filter A filter name to apply.
* @param mixed|null $flags
* @param array|int|null $flags
*
* @return mixed
* @return array|bool|float|int|object|string|null
*/
public function getGet($index = null, $filter = null, $flags = null)
{
Expand All @@ -785,9 +785,9 @@ public function getGet($index = null, $filter = null, $flags = null)
*
* @param array|string|null $index Index for item to fetch from $_POST.
* @param int|null $filter A filter name to apply
* @param mixed $flags
* @param array|int|null $flags
*
* @return mixed
* @return array|bool|float|int|object|string|null
*/
public function getPost($index = null, $filter = null, $flags = null)
{
Expand All @@ -799,9 +799,9 @@ public function getPost($index = null, $filter = null, $flags = null)
*
* @param array|string|null $index Index for item to fetch from $_POST or $_GET
* @param int|null $filter A filter name to apply
* @param mixed $flags
* @param array|int|null $flags
*
* @return mixed
* @return array|bool|float|int|object|string|null
*/
public function getPostGet($index = null, $filter = null, $flags = null)
{
Expand All @@ -821,9 +821,9 @@ public function getPostGet($index = null, $filter = null, $flags = null)
*
* @param array|string|null $index Index for item to be fetched from $_GET or $_POST
* @param int|null $filter A filter name to apply
* @param mixed $flags
* @param array|int|null $flags
*
* @return mixed
* @return array|bool|float|int|object|string|null
*/
public function getGetPost($index = null, $filter = null, $flags = null)
{
Expand All @@ -843,9 +843,9 @@ public function getGetPost($index = null, $filter = null, $flags = null)
*
* @param array|string|null $index Index for item to be fetched from $_COOKIE
* @param int|null $filter A filter name to be applied
* @param mixed $flags
* @param array|int|null $flags
*
* @return mixed
* @return array|bool|float|int|object|string|null
*/
public function getCookie($index = null, $filter = null, $flags = null)
{
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/RequestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function setGlobal(string $method, $value)
* @param int|null $filter Filter constant
* @param array|int|null $flags Options
*
* @return array|bool|string|null
* @return array|bool|float|int|object|string|null
*/
public function fetchGlobal(string $method, $index = null, ?int $filter = null, $flags = null)
{
Expand Down
2 changes: 2 additions & 0 deletions user_guide_src/source/general/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=====================================

Expand Down
68 changes: 53 additions & 15 deletions user_guide_src/source/general/environments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,44 @@ tools loaded that you don't in production environments, etc.

.. contents::
:local:
:depth: 2
:depth: 3

************************
The Defined Environments
************************

By default, CodeIgniter has three environments defined.

- ``production`` for production
- ``development`` for development
- ``testing`` for PHPUnit testing

.. 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`_.

*******************
Setting Environment
*******************

.. _environment-constant:

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.

.. note:: The environment ``testing`` is the special one 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``.

.. 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
----

The simplest method to set the variable is in your :doc:`.env file </general/configuration>`.
The simplest method to set the variable is in your :ref:`.env file <dotenv-file>`.

.. code-block:: ini
Expand Down Expand Up @@ -88,8 +103,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
Expand All @@ -102,15 +123,32 @@ 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.

**********************************
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
=====================================
*************************************

There are some places in the CodeIgniter system where the ``ENVIRONMENT``
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.
Expand Down
20 changes: 10 additions & 10 deletions user_guide_src/source/incoming/incomingrequest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ The methods provided by the parent classes that are available are:
:param int $flags: Flags to apply. A list of flags can be found
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
:returns: ``$_REQUEST`` if no parameters supplied, otherwise the REQUEST value if found, or null if not
:rtype: mixed|null
:rtype: array|bool|float|int|object|string|null

The first parameter will contain the name of the REQUEST item you are looking for:

Expand Down Expand Up @@ -360,7 +360,7 @@ The methods provided by the parent classes that are available are:
:param int $flags: Flags to apply. A list of flags can be found
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
:returns: ``$_GET`` if no parameters supplied, otherwise the GET value if found, or null if not
:rtype: mixed|null
:rtype: array|bool|float|int|object|string|null

This method is identical to ``getVar()``, only it fetches GET data.

Expand All @@ -372,7 +372,7 @@ The methods provided by the parent classes that are available are:
:param int $flags: Flags to apply. A list of flags can be found
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
:returns: ``$_POST`` if no parameters supplied, otherwise the POST value if found, or null if not
:rtype: mixed|null
:rtype: array|bool|float|int|object|string|null

This method is identical to ``getVar()``, only it fetches POST data.

Expand All @@ -385,7 +385,7 @@ The methods provided by the parent classes that are available are:
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
:returns: ``$_POST`` and ``$_GET`` combined if no parameters specified (prefer POST value on conflict),
otherwise looks for POST value, if nothing found looks for GET value, if no value found returns null
:rtype: mixed|null
:rtype: array|bool|float|int|object|string|null

This method works pretty much the same way as ``getPost()`` and ``getGet()``, only combined.
It will search through both POST and GET streams for data, looking first in POST, and
Expand All @@ -405,7 +405,7 @@ The methods provided by the parent classes that are available are:
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
:returns: ``$_GET`` and ``$_POST`` combined if no parameters specified (prefer GET value on conflict),
otherwise looks for GET value, if nothing found looks for POST value, if no value found returns null
:rtype: mixed|null
:rtype: array|bool|float|int|object|string|null

This method works pretty much the same way as ``getPost()`` and ``getGet()``, only combined.
It will search through both GET and POST streams for data, looking first in GET, and
Expand All @@ -418,13 +418,13 @@ The methods provided by the parent classes that are available are:

.. php:method:: getCookie([$index = null[, $filter = null[, $flags = null]]])
:param mixed $index: COOKIE name
:param array|string|null $index: COOKIE name
:param int $filter: The type of filter to apply. A list of filters can be
found `here <https://www.php.net/manual/en/filter.filters.php>`__.
:param int $flags: Flags to apply. A list of flags can be found
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
:returns: ``$_COOKIE`` if no parameters supplied, otherwise the COOKIE value if found or null if not
:rtype: mixed
:rtype: array|bool|float|int|object|string|null

This method is identical to ``getPost()`` and ``getGet()``, only it fetches cookie data:

Expand All @@ -440,13 +440,13 @@ The methods provided by the parent classes that are available are:

.. php:method:: getServer([$index = null[, $filter = null[, $flags = null]]])
:param mixed $index: Value name
:param array|string|null $index: Value name
:param int $filter: The type of filter to apply. A list of filters can be
found `here <https://www.php.net/manual/en/filter.filters.php>`__.
:param int $flags: Flags to apply. A list of flags can be found
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
:returns: ``$_SERVER`` item value if found, null if not
:rtype: mixed
:rtype: array|bool|float|int|object|string|null

This method is identical to the ``getPost()``, ``getGet()`` and ``getCookie()``
methods, only it fetches getServer data (``$_SERVER``):
Expand All @@ -463,7 +463,7 @@ The methods provided by the parent classes that are available are:
:param int $filter: The type of filter to apply. A list of filters can be
found `here <https://www.php.net/manual/en/filter.filters.php>`__.
:returns: The User Agent string, as found in the SERVER data, or null if not found.
:rtype: mixed
:rtype: CodeIgniter\\HTTP\\UserAgent

This method returns the User Agent string from the SERVER data:

Expand Down

0 comments on commit fea41d8

Please sign in to comment.