This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from sunrise-php/release/v1.2.5
v1.2.5
- Loading branch information
Showing
2 changed files
with
3 additions
and
97 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 |
---|---|---|
@@ -1,96 +1 @@ | ||
## URI wrapper for PHP 7.1+ based on RFC-3986, PSR-7 and PSR-17 | ||
|
||
[![Gitter](https://badges.gitter.im/sunrise-php/support.png)](https://gitter.im/sunrise-php/support) | ||
[![Build Status](https://scrutinizer-ci.com/g/sunrise-php/uri/badges/build.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/uri/build-status/master) | ||
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/sunrise-php/uri/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/uri/?branch=master) | ||
[![Code Coverage](https://scrutinizer-ci.com/g/sunrise-php/uri/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/uri/?branch=master) | ||
[![Latest Stable Version](https://poser.pugx.org/sunrise/uri/v/stable?format=flat)](https://packagist.org/packages/sunrise/uri) | ||
[![Total Downloads](https://poser.pugx.org/sunrise/uri/downloads?format=flat)](https://packagist.org/packages/sunrise/uri) | ||
[![License](https://poser.pugx.org/sunrise/uri/license?format=flat)](https://packagist.org/packages/sunrise/uri) | ||
|
||
--- | ||
|
||
## Installation | ||
|
||
```bash | ||
composer require sunrise/uri | ||
``` | ||
|
||
## How to use? | ||
|
||
```php | ||
use Sunrise\Uri\Uri; | ||
use Sunrise\Uri\UriFactory; | ||
|
||
// creates a new URI | ||
$uri = new Uri('http://user:pass@localhost:3000/path?query#fragment'); | ||
|
||
// creates a new URI with a factory (is equivalent to new Uri(string)) | ||
$uri = (new UriFactory)->createUri('http://user:pass@localhost:3000/path?query#fragment'); | ||
|
||
// list of withers | ||
$uri->withScheme(); | ||
$uri->withUserInfo(); | ||
$uri->withHost(); | ||
$uri->withPort(); | ||
$uri->withPath(); | ||
$uri->withQuery(); | ||
$uri->withFragment(); | ||
|
||
// list of getters | ||
$uri->getScheme(); | ||
$uri->getUserInfo(); | ||
$uri->getHost(); | ||
$uri->getPort(); | ||
$uri->getPath(); | ||
$uri->getQuery(); | ||
$uri->getFragment(); | ||
$uri->getAuthority(); | ||
|
||
// converts the URI to a string | ||
(string) $uri; | ||
``` | ||
|
||
### Another schemes | ||
|
||
```php | ||
$uri = new Uri('mailto:[email protected]'); | ||
|
||
$uri->getScheme(); // mailto | ||
$uri->getPath(); // [email protected] | ||
``` | ||
|
||
```php | ||
$uri = new Uri('maps:?q=112+E+Chapman+Ave+Orange,+CA+92866'); | ||
|
||
$uri->getScheme(); // maps | ||
$uri->getQuery(); // q=112+E+Chapman+Ave+Orange,+CA+92866 | ||
``` | ||
|
||
```php | ||
$uri = new Uri('tel:+1-816-555-1212'); | ||
|
||
$uri->getScheme(); // tel | ||
$uri->getPath(); // +1-816-555-1212 | ||
``` | ||
|
||
```php | ||
$uri = new Uri('urn:oasis:names:specification:docbook:dtd:xml:4.1.2'); | ||
|
||
$uri->getScheme(); // urn | ||
$uri->getPath(); // oasis:names:specification:docbook:dtd:xml:4.1.2 | ||
``` | ||
|
||
--- | ||
|
||
## Test run | ||
|
||
```bash | ||
php vendor/bin/phpunit | ||
``` | ||
|
||
## Useful links | ||
|
||
* https://tools.ietf.org/html/rfc3986 | ||
* https://www.php-fig.org/psr/psr-7/ | ||
* https://www.php-fig.org/psr/psr-17/ | ||
⚠️ This package was **moved** to the [http-message](https://github.com/sunrise-php/http-message) package and is abandoned. |
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