-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding more URI string representation (#150)
- Loading branch information
Showing
8 changed files
with
316 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,10 +122,6 @@ echo $uri->getPath(); //displays "/how/are/you" | |
echo $uri->getQuery(); //displays "foo=baz" | ||
echo $uri->getFragment(); //displays "title" | ||
echo $uri->getOrigin(); //returns '' | ||
echo $uri->toString(); | ||
//displays "http://foo:[email protected]:81/how/are/you?foo=baz#title" | ||
echo json_encode($uri); | ||
//displays "http:\/\/foo:[email protected]:81\/how\/are\/you?foo=baz#title" | ||
$uri->getComponents(); | ||
// returns array { | ||
// "scheme" => "http", | ||
|
@@ -253,6 +249,32 @@ Uri::new('https://example.com/123') | |
|
||
The method takes into account i18n while comparing both URI if the PHP's `idn_*` functions can be used. | ||
|
||
## URI string representation | ||
|
||
The `Uri` class handles URI according to RFC3986 as such you can retrieve its string representation using the | ||
`toString` method. But `URI` can have multiple string representation depending on its scheme or context. As | ||
such the package provides several other string representations: | ||
|
||
```php | ||
use League\Uri\Uri; | ||
|
||
$uri = Uri::new("http://foo:[email protected]:81/how/are/you?foo=baz#title"); | ||
|
||
echo $uri->toString(); //displays RFC3986 string representation | ||
echo $uri; //displays RFC3986 string representation | ||
echo json_encode($uri); //display JSON encoded string representation | ||
|
||
/** | ||
* NEW in version 7.6+ | ||
*/ | ||
|
||
echo $uri->toNormalizedString(); //displays the normalized URI string representation | ||
echo $uri->toDisplayString(); //displays the URI display representation | ||
echo $uri->toRfc8089String(); //display the string file representation according to RFC8089 or null if the scheme is not file | ||
echo $uri->toUnixPath(); //display the string path as a Unix Path or null if the scheme is not file | ||
echo $uri->toWindowsPath(); //display the string path as a Windows Path or null if the scheme is not file | ||
``` | ||
|
||
## Modifying URI properties | ||
|
||
Use the modifying methods exposed by all URI instances to replace one of the URI component. | ||
|
@@ -379,3 +401,4 @@ $uri->equals('eXAMPLE://a/./b/../b/%63/%7bfoo%7d', excludeFragment: false); // r | |
|
||
In the last example the `equals` method took into account the URI `fragment` component. The `isSameDocument` | ||
follow closely RFC3986 and never takes into account the URI `fragment` component. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.