Skip to content

Commit 69d35ef

Browse files
committed
docs: add user guide
1 parent c140ee4 commit 69d35ef

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

user_guide_src/source/changelogs/v4.3.0.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ Error Handling
244244
- To *temporarily* enable throwing of deprecations, set the environment variable ``CODEIGNITER_SCREAM_DEPRECATIONS`` to a truthy value.
245245
- ``Config\Logger::$threshold`` is now, by default, environment-specific. For production environment, default threshold is still ``4`` but changed to ``9`` for other environments.
246246

247+
Multiple Domain Support
248+
=======================
249+
250+
- Added ``Config\App::$allowedHostnames`` to set hostnames other than the hostname in the baseURL.
251+
- If you set ``Config\App::$allowedHostnames``, URL-related functions such as :php:func:`base_url()`, :php:func:`current_url()`, :php:func:`site_url()` will return the URL with the hostname set in ``Config\App::$allowedHostnames`` if the current URL matches.
252+
247253
Others
248254
======
249255

user_guide_src/source/helpers/url_helper.rst

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ The following functions are available:
2020

2121
.. php:function:: site_url([$uri = ''[, $protocol = null[, $altConfig = null]]])
2222
23-
:param mixed $uri: URI string or array of URI segments
23+
:param array|string $uri: URI string or array of URI segments
2424
:param string $protocol: Protocol, e.g., 'http' or 'https'
2525
:param \\Config\\App $altConfig: Alternate configuration to use
2626
:returns: Site URL
2727
:rtype: string
2828

29-
Returns your site URL, as specified in your config file. The index.php
30-
file (or whatever you have set as your site **indexPage** in your config
29+
.. note:: Since v4.3.0, if you set ``Config\App::$allowedHostnames``,
30+
this returns the URL with the hostname set in it if the current URL matches.
31+
32+
Returns your site URL, as specified in your config file. The **index.php**
33+
file (or whatever you have set as your site ``Config\App::$indexPage`` in your config
3134
file) will be added to the URL, as will any URI segments you pass to the
3235
function.
3336

@@ -41,7 +44,7 @@ The following functions are available:
4144
.. literalinclude:: url_helper/001.php
4245

4346
The above example would return something like:
44-
*http://example.com/index.php/news/local/123*
47+
**http://example.com/index.php/news/local/123**
4548

4649
Here is an example of segments passed as an array:
4750

@@ -53,33 +56,36 @@ The following functions are available:
5356

5457
.. php:function:: base_url([$uri = ''[, $protocol = null]])
5558
56-
:param mixed $uri: URI string or array of URI segments
59+
:param array|string $uri: URI string or array of URI segments
5760
:param string $protocol: Protocol, e.g., 'http' or 'https'
5861
:returns: Base URL
5962
:rtype: string
6063

64+
.. note:: Since v4.3.0, if you set ``Config\App::$allowedHostnames``,
65+
this returns the URL with the hostname set in it if the current URL matches.
66+
6167
Returns your site base URL, as specified in your config file. Example:
6268

6369
.. literalinclude:: url_helper/003.php
6470

6571
This function returns the same thing as :php:func:`site_url()`, without
66-
the *indexPage* being appended.
72+
the ``Config\App\$indexPage`` being appended.
6773

6874
Also like :php:func:`site_url()`, you can supply segments as a string or
6975
an array. Here is a string example:
7076

7177
.. literalinclude:: url_helper/004.php
7278

7379
The above example would return something like:
74-
*http://example.com/blog/post/123*
80+
**http://example.com/blog/post/123**
7581

7682
This is useful because unlike :php:func:`site_url()`, you can supply a
7783
string to a file, such as an image or stylesheet. For example:
7884

7985
.. literalinclude:: url_helper/005.php
8086

8187
This would give you something like:
82-
*http://example.com/images/icons/edit.png*
88+
**http://example.com/images/icons/edit.png**
8389

8490
.. php:function:: current_url([$returnObject = false[, $request = null]])
8591
@@ -89,14 +95,18 @@ The following functions are available:
8995
:rtype: string|\\CodeIgniter\\HTTP\\URI
9096

9197
Returns the full URL (including segments) of the page being currently viewed.
98+
9299
However for security reasons, it is created based on the ``Config\App`` settings,
93100
and not intended to match the browser URL.
94101

102+
Since v4.3.0, if you set ``Config\App::$allowedHostnames``,
103+
this returns the URL with the hostname set in it if the current URL matches.
104+
95105
.. note:: Calling this function is the same as doing this:
96106

97107
.. literalinclude:: url_helper/006.php
98108

99-
.. important:: Prior to v4.1.2, this function had a bug causing it to ignore the configuration on ``App::$indexPage``.
109+
.. important:: Prior to v4.1.2, this function had a bug causing it to ignore the configuration on ``Config\App::$indexPage``.
100110

101111
.. php:function:: previous_url([$returnObject = false])
102112

user_guide_src/source/installation/upgrade_430.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ Others
193193
Breaking Enhancements
194194
*********************
195195

196+
Multiple Domain Support
197+
=======================
198+
199+
- If you set ``Config\App::$allowedHostnames``, URL-related functions such as :php:func:`base_url()`, :php:func:`current_url()`, :php:func:`site_url()` will return the URL with the hostname set in ``Config\App::$allowedHostnames`` if the current URL matches.
200+
201+
Others
202+
======
203+
196204
- Since void HTML elements (e.g. ``<input>``) in ``html_helper``, ``form_helper`` or common functions have been changed to be HTML5-compatible by default and you need to be compatible with XHTML, you must set the ``$html5`` property in **app/Config/DocTypes.php** to ``false``.
197205
- Since the launch of Spark Commands was extracted from ``CodeIgniter\CodeIgniter``, there may be problems running these commands if the ``Services::codeigniter()`` service has been overridden.
198206
- The return type of ``CodeIgniter\Database\Database::loadForge()`` has been changed to ``Forge``. Extending classes should likewise change the type.

0 commit comments

Comments
 (0)