|
1 | | -## URI wrapper for PHP 7.1+ based on RFC-3986, PSR-7 and PSR-17 |
2 | | - |
3 | | -[](https://gitter.im/sunrise-php/support) |
4 | | -[](https://scrutinizer-ci.com/g/sunrise-php/uri/build-status/master) |
5 | | -[](https://scrutinizer-ci.com/g/sunrise-php/uri/?branch=master) |
6 | | -[](https://scrutinizer-ci.com/g/sunrise-php/uri/?branch=master) |
7 | | -[](https://packagist.org/packages/sunrise/uri) |
8 | | -[](https://packagist.org/packages/sunrise/uri) |
9 | | -[](https://packagist.org/packages/sunrise/uri) |
10 | | - |
11 | | ---- |
12 | | - |
13 | | -## Installation |
14 | | - |
15 | | -```bash |
16 | | -composer require sunrise/uri |
17 | | -``` |
18 | | - |
19 | | -## How to use? |
20 | | - |
21 | | -```php |
22 | | -use Sunrise\Uri\Uri; |
23 | | -use Sunrise\Uri\UriFactory; |
24 | | - |
25 | | -// creates a new URI |
26 | | -$uri = new Uri('http://user:pass@localhost:3000/path?query#fragment'); |
27 | | - |
28 | | -// creates a new URI with a factory (is equivalent to new Uri(string)) |
29 | | -$uri = (new UriFactory)->createUri('http://user:pass@localhost:3000/path?query#fragment'); |
30 | | - |
31 | | -// list of withers |
32 | | -$uri->withScheme(); |
33 | | -$uri->withUserInfo(); |
34 | | -$uri->withHost(); |
35 | | -$uri->withPort(); |
36 | | -$uri->withPath(); |
37 | | -$uri->withQuery(); |
38 | | -$uri->withFragment(); |
39 | | - |
40 | | -// list of getters |
41 | | -$uri->getScheme(); |
42 | | -$uri->getUserInfo(); |
43 | | -$uri->getHost(); |
44 | | -$uri->getPort(); |
45 | | -$uri->getPath(); |
46 | | -$uri->getQuery(); |
47 | | -$uri->getFragment(); |
48 | | -$uri->getAuthority(); |
49 | | - |
50 | | -// converts the URI to a string |
51 | | -(string) $uri; |
52 | | -``` |
53 | | - |
54 | | -### Another schemes |
55 | | - |
56 | | -```php |
57 | | -$uri = new Uri('mailto:test@example.com'); |
58 | | - |
59 | | -$uri->getScheme(); // mailto |
60 | | -$uri->getPath(); // test@example.com |
61 | | -``` |
62 | | - |
63 | | -```php |
64 | | -$uri = new Uri('maps:?q=112+E+Chapman+Ave+Orange,+CA+92866'); |
65 | | - |
66 | | -$uri->getScheme(); // maps |
67 | | -$uri->getQuery(); // q=112+E+Chapman+Ave+Orange,+CA+92866 |
68 | | -``` |
69 | | - |
70 | | -```php |
71 | | -$uri = new Uri('tel:+1-816-555-1212'); |
72 | | - |
73 | | -$uri->getScheme(); // tel |
74 | | -$uri->getPath(); // +1-816-555-1212 |
75 | | -``` |
76 | | - |
77 | | -```php |
78 | | -$uri = new Uri('urn:oasis:names:specification:docbook:dtd:xml:4.1.2'); |
79 | | - |
80 | | -$uri->getScheme(); // urn |
81 | | -$uri->getPath(); // oasis:names:specification:docbook:dtd:xml:4.1.2 |
82 | | -``` |
83 | | - |
84 | | ---- |
85 | | - |
86 | | -## Test run |
87 | | - |
88 | | -```bash |
89 | | -php vendor/bin/phpunit |
90 | | -``` |
91 | | - |
92 | | -## Useful links |
93 | | - |
94 | | -* https://tools.ietf.org/html/rfc3986 |
95 | | -* https://www.php-fig.org/psr/psr-7/ |
96 | | -* https://www.php-fig.org/psr/psr-17/ |
| 1 | +⚠️ This package was **moved** to the [http-message](https://github.com/sunrise-php/http-message) package and is abandoned. |
0 commit comments