@@ -14,34 +14,47 @@ relative URI to an existing one and have it resolved safely and correctly.
1414Creating URI instances
1515======================
1616
17- Creating a URI instance is as simple as creating a new class instance:
17+ Creating a URI instance is as simple as creating a new class instance.
18+
19+ When you create the new instance, you can pass a full or partial URL in the constructor and it will be parsed
20+ into its appropriate sections:
1821
1922.. literalinclude :: uri/001.php
23+ :lines: 2-
2024
21- Alternatively, you can use the `` service() ` ` function to return an instance for you:
25+ Alternatively, you can use the :php:func: ` service() ` function to return an instance for you:
2226
23- .. literalinclude :: uri/002.php
27+ .. literalinclude :: uri/003.php
28+ :lines: 2-
2429
25- When you create the new instance, you can pass a full or partial URL in the constructor and it will be parsed
26- into its appropriate sections:
30+ Since v4.4.0, if you don't pass a URL, it returns the current URI:
2731
28- .. literalinclude :: uri/003.php
32+ .. literalinclude :: uri/002.php
33+ :lines: 2-
34+
35+ .. note :: The above code returns the ``SiteURI`` instance, that extends the ``URI``
36+ class. The ``URI `` class is for general URIs, but the ``SiteURI `` class is
37+ for your site URIs.
2938
3039The Current URI
3140---------------
3241
3342Many times, all you really want is an object representing the current URL of this request.
34- You can use one of the functions available in the :doc: `../helpers/url_helper `:
43+ You can use the :php:func: ` current_url() ` function available in the :doc: `../helpers/url_helper `:
3544
3645.. literalinclude :: uri/004.php
46+ :lines: 2-
3747
3848You must pass ``true `` as the first parameter, otherwise, it will return the string representation of the current URL.
3949
4050This URI is based on the path (relative to your ``baseURL ``) as determined by the current request object and
4151your settings in ``Config\App `` (``baseURL ``, ``indexPage ``, and ``forceGlobalSecureRequests ``).
42- Assuming that you're in a controller that extends ``CodeIgniter\Controller `` you can get this relative path:
52+
53+ Assuming that you're in a controller that extends ``CodeIgniter\Controller ``, you
54+ can also get the current SiteURI instance:
4355
4456.. literalinclude :: uri/005.php
57+ :lines: 2-
4558
4659===========
4760URI Strings
@@ -136,6 +149,10 @@ can be used to manipulate it:
136149.. note :: When setting the path this way, or any other way the class allows, it is sanitized to encode any dangerous
137150 characters, and remove dot segments for safety.
138151
152+ .. note :: Since v4.4.0, the ``SiteURI::getRoutePath()`` method,
153+ returns the URI path relative to baseURL, and the ``SiteURI::getPath() ``
154+ method always returns the full URI path with leading ``/ ``.
155+
139156Query
140157-----
141158
0 commit comments