-
-
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.
- Loading branch information
Showing
1 changed file
with
7 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,8 +111,6 @@ The `Uri` class handles URI according to RFC3986 as such you can retrieve its st | |
`toString` method. | ||
|
||
```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 | ||
|
@@ -126,8 +124,6 @@ The `Uri` instance can be json encoded using the same URI representation from Ja | |
easier interoperability | ||
|
||
```php | ||
use League\Uri\Uri; | ||
|
||
$uri = Uri::new("http://foo:[email protected]:81/how/are/you?foo=baz#title"); | ||
json_encode($uri); //returns "http:\/\/foo:[email protected]:81\/how\/are\/you?foo=baz#title" | ||
``` | ||
|
@@ -141,8 +137,6 @@ may represent an invalid URI but can be used to display the URI to the client fo | |
content of a `a` HTML tag. | ||
|
||
```php | ||
use League\Uri\Uri; | ||
|
||
$uri = Uri::new('eXAMPLE://a/./b/../b/%63/%7bfoo%7d?foo[]=bar'); | ||
echo $uri->toString(); //displays 'example://a/./b/../b/%63/%7bfoo%7d?foo%5B%5D=bar' | ||
echo $uri->toNormalizedString(); //displays 'example://a/b/c/%7Bfoo%7D?foo%5B%5D=bar' | ||
|
@@ -152,8 +146,6 @@ echo $uri->toDisplayString(); //displays 'example://a/b/c/{foo}?foo[]=bar' | |
HTML specific representation are added to allow adding URI to your HTML/Markdown page. | ||
|
||
```php | ||
use League\Uri\Uri; | ||
|
||
$uri = Uri::new('eXAMPLE://a/./b/../b/%63/%7bfoo%7d?foo[]=bar'); | ||
echo $uri->toMarkdown(); | ||
//display '[example://a/b/c/{foo}?foo[]=bar](example://a/./b/../b/%63/%7bfoo%7d?foo%5B%5D=bar) | ||
|
@@ -168,8 +160,6 @@ echo $uri->toAnchorTag('my link'); | |
You can also generate the Link `tag` and/or `header` depending on how you want your URI link to be rendered: | ||
|
||
```php | ||
use League\Uri\Uri; | ||
|
||
$uri = Uri::new('https://example.com/my/css/v1.3'); | ||
echo $uri->toLinkTag(['rel' => 'stylesheet']); | ||
//display '<link href="https://example.com/my/css/v1.3" rel="stylesheet"> | ||
|
@@ -180,8 +170,6 @@ echo $uri->toLinkFieldValue(['rel' => 'stylesheet']); | |
File specific representation are added to allow representing Unix and Windows Path. | ||
|
||
```php | ||
use League\Uri\Uri; | ||
|
||
$uri = Uri::new('file:///c:/windows/My%20Documents%20100%2520/foo.txt'); | ||
echo $uri->toWindowsPath(); //display 'c:\windows\My Documents 100%20\foo.txt' | ||
|
||
|
@@ -378,24 +366,21 @@ $uri = Uri::new("ftp://thephpleague.com/fr/") | |
echo $uri; //displays yolo://foo:[email protected]:81?foo=baz#fine | ||
~~~ | ||
|
||
<p class="message-notice">The <code>withUser</code> and <code>withPassword</code> methods are available | ||
since version <code>7.6.0</code> to be inline with PHP native <code>Uri</code> interface.</p> | ||
|
||
<p class="message-notice">The <code>when</code> method is available since version <code>7.6.0</code></p> | ||
To ease building the instance, the `when` method is added to conditionally create your component. | ||
|
||
```php | ||
use League\Uri\Uri; | ||
<p class="message-notice">The <code>withUser</code> and <code>withPassword</code> methods are available | ||
since version <code>7.6.0</code> to be inline with PHP native <code>Uri</code> interface.</p> | ||
|
||
$foo = ''; | ||
```php | ||
echo Uri::new('https://uri.thephpleague.com/components/7.0/modifiers/') | ||
->when( | ||
'' !== $foo, | ||
fn (Uri $uri) => $uri->withPath('/'.$foo), //on true | ||
fn (Uri $uri) => $uri->withPath('/default'), //on false | ||
fn (Uri $uri) => $uri->getPassword() !== null, | ||
fn (Uri $uri) => $uri->withQuery('access=allowed'), //on true | ||
fn (Uri $uri) => $uri->withQuery('access=deny'), //on false | ||
) | ||
->toString(); | ||
// returns 'https://uri.thephpleague.com/default'; | ||
// returns 'https://uri.thephpleague.com/components/7.0/modifiers/?access=deny'; | ||
``` | ||
|
||
## URI resolution | ||
|