Skip to content

Commit 756d51b

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into docs-update-cli-generators
2 parents 84d206a + 848c598 commit 756d51b

8 files changed

Lines changed: 103 additions & 29 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"phpunit/phpcov": "^8.2",
2525
"phpunit/phpunit": "^9.1",
2626
"predis/predis": "^1.1 || ^2.0",
27-
"rector/rector": "0.15.23",
27+
"rector/rector": "0.15.24",
2828
"vimeo/psalm": "^5.0"
2929
},
3030
"suggest": {

contributing/documentation.rst

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,12 @@ Writing CodeIgniter Documentation
33
#################################
44

55
CodeIgniter uses Sphinx to generate its documentation in a variety of formats,
6-
using reStructuredText to handle the formatting. If you are familiar with
6+
using `reStructuredText`_ to handle the formatting. If you are familiar with
77
Markdown or Textile, you will quickly grasp reStructuredText. The focus is
88
on readability and user friendliness.
99
While they can be quite technical, we always write for humans!
1010

11-
A local table of contents should always be included, like the one below.
12-
It is created automatically by inserting the following::
13-
14-
.. contents::
15-
:local:
16-
:depth: 2
11+
.. _reStructuredText: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
1712

1813
.. contents::
1914
:local:
@@ -26,7 +21,18 @@ To see the rendered HTML, ePub, PDF, etc., you will need to install Sphinx
2621
along with the PHP domain extension for Sphinx. The underlying requirement
2722
is to have Python installed.
2823

29-
You can read more about installing all tools in /user_guide_src/README.rst
24+
You can read more about installing all tools in **user_guide_src/README.rst**
25+
26+
*****************
27+
Table of Contents
28+
*****************
29+
30+
A local table of contents should always be included, like the one below.
31+
It is created automatically by inserting the following::
32+
33+
.. contents::
34+
:local:
35+
:depth: 2
3036

3137
*****************************************
3238
Page and Section Headings and Subheadings
@@ -119,15 +125,21 @@ You can reference a page like the following::
119125
To a URL
120126
========
121127

128+
::
129+
122130
`CodeIgniter 4 framework <https://github.com/codeigniter4/framework>`_
123131

124132
To a Function
125133
=============
126134

135+
::
136+
127137
:php:func:`dot_array_search()`
128138

129139
To a Method
130-
=============
140+
===========
141+
142+
::
131143

132144
:php:meth:`CodeIgniter\\HTTP\\Response::setCookie()`
133145

@@ -138,10 +150,24 @@ Other Directives
138150
New Feature
139151
===========
140152

153+
::
154+
141155
.. versionadded:: 4.3.0
142156

143157
Deprecated
144158
==========
145159

160+
::
161+
146162
.. deprecated:: 4.3.0
147163
Use :php:meth:`CodeIgniter\\Database\\BaseBuilder::setData()` instead.
164+
165+
***************
166+
Text Decoration
167+
***************
168+
169+
As a general rule, we use ``**`` for in-line file paths, and `````` for source code.
170+
171+
E.g.::
172+
173+
Open the **app/Config/Filters.php** file and update the ``$methods`` property like the following:

user_guide_src/source/general/configuration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ One of today's best practices for application setup is to use Environment Variab
6363

6464
Environment Variables should also be used for anything private such as passwords, API keys, or other sensitive data.
6565

66+
.. _dotenv-file:
67+
6668
Environment Variables and CodeIgniter
6769
=====================================
6870

user_guide_src/source/general/environments.rst

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1839
The 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
88103
section), you may use this constant in your own development to
89104
differentiate 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+
91112
Boot Files
92-
----------
113+
==========
93114

94115
CodeIgniter requires that a PHP script matching the environment's name is located
95116
under **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+
*************************************
105143
Effects on Default Framework Behavior
106-
=====================================
144+
*************************************
107145

108146
There are some places in the CodeIgniter system where the ``ENVIRONMENT``
109147
constant is used. This section describes how default framework behavior
110148
is affected.
111149

112150
Error Reporting
113-
---------------
151+
===============
114152

115153
Setting the ``ENVIRONMENT`` constant to a value of ``development`` will cause
116154
all PHP errors to be rendered to the browser when they occur.

user_guide_src/source/installation/upgrade_4xx.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ Application Structure
6262
Routing
6363
=======
6464

65-
- The Auto Routing is disabled by default. If you want to use the Auto Routing in the same way as CI3, you need to enable :ref:`auto-routing-legacy`.
65+
- The Auto Routing is disabled by default. You need to :ref:`define all routes
66+
<defined-route-routing>` by default.
67+
- If you want to use the Auto Routing in the same way as CI3, you need to enable
68+
:ref:`auto-routing-legacy`.
6669
- CI4 also has an optional new more secure :ref:`auto-routing-improved`.
6770

6871
Model, View and Controller
@@ -204,6 +207,3 @@ Upgrading Libraries
204207
upgrade_sessions
205208
upgrade_validations
206209
upgrade_view_parser
207-
208-
.. note::
209-
More upgrade guides coming soon

user_guide_src/source/installation/upgrade_validations.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ What has been changed
1515
=====================
1616
- If you want to change validation error display, you have to set CI4 :ref:`validation View templates <validation-customizing-error-display>`.
1717
- CI4 validation has no Callbacks nor Callable in CI3.
18+
Use :ref:`Rule Classes <validation-using-rule-classes>` or
19+
:ref:`Closure Rule <validation-using-closure-rule>`
20+
instead.
1821
- CI4 validation format rules do not permit empty string.
1922
- CI4 validation never changes your data.
2023
- Since v4.3.0, :php:func:`validation_errors()` has been introduced, but the API is different from CI3's.

user_guide_src/source/libraries/security.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ Redirection on Failure
121121
Since v4.3.0, when a request fails the CSRF validation check,
122122
it will throw a SecurityException by default,
123123

124+
.. note:: In production environment, when you use HTML forms, it is recommended
125+
to enable this redirection for a better user experience.
126+
124127
If you want to make it redirect to the previous page,
125128
change the following config parameter value in
126129
**app/Config/Security.php**:

user_guide_src/source/libraries/validation.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ right after the name of the field the error should belong to::
612612
Creating Custom Rules
613613
*********************
614614

615+
.. _validation-using-rule-classes:
616+
615617
Using Rule Classes
616618
==================
617619

0 commit comments

Comments
 (0)