Skip to content

Commit

Permalink
Merge pull request #5345 from kenjis/fix-request-uri
Browse files Browse the repository at this point in the history
docs: don't use `IncomingRequest::$uri`
  • Loading branch information
kenjis authored Nov 20, 2021
2 parents c3e43e9 + 05ce6cb commit 13af9e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions system/HTTP/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class IncomingRequest extends Request
* AFTER the script name. So, if hosted in a sub-folder this will
* appear different than actual URL. If you need that use getPath().
*
* @TODO should be protected. Use getUri() instead.
*
* @var URI
*/
public $uri;
Expand Down
2 changes: 1 addition & 1 deletion user_guide_src/source/concepts/http.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ is an object-oriented representation of the HTTP request. It provides everything
$request = service('request');

// the URI being requested (i.e., /about)
$request->uri->getPath();
$request->getUri()->getPath();

// Retrieve $_GET and $_POST variables
$request->getGet('foo');
Expand Down
6 changes: 3 additions & 3 deletions user_guide_src/source/incoming/incomingrequest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ The Request URL
---------------

You can retrieve a :doc:`URI </libraries/uri>` object that represents the current URI for this request through the
``$request->uri`` property. You can cast this object as a string to get a full URL for the current request::
``$request->getUri()`` method. You can cast this object as a string to get a full URL for the current request::

$uri = (string)$request->uri;
$uri = (string) $request->getUri();

The object gives you full abilities to grab any part of the request on it's own::

$uri = $request->uri;
$uri = $request->getUri();

echo $uri->getScheme(); // http
echo $uri->getAuthority(); // snoopy:[email protected]:88
Expand Down

0 comments on commit 13af9e5

Please sign in to comment.