https://github.com/kusabi/uri
A PSR-7 and PSR-17 conforming uri library for PHP
https://github.com/kusabi/uri
php psr-17 psr-7 uri url
Last synced: 7 months ago
JSON representation
A PSR-7 and PSR-17 conforming uri library for PHP
- Host: GitHub
- URL: https://github.com/kusabi/uri
- Owner: kusabi
- License: mit
- Created: 2019-03-27T11:14:34.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2020-10-31T13:20:06.000Z (almost 5 years ago)
- Last Synced: 2025-01-18T10:27:18.245Z (9 months ago)
- Topics: php, psr-17, psr-7, uri, url
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Contributing: .github/contributing.md
- Code of conduct: .github/code_of_conduct.md
Awesome Lists containing this project
README
# Uri wrapper

[](https://codecov.io/gh/kusabi/uri)
[](https://img.shields.io/github/license/kusabi/uri.svg)
[](https://img.shields.io/github/release/kusabi/uri.svg)
[](https://img.shields.io/github/tag/kusabi/uri.svg)
[](https://img.shields.io/github/issues/kusabi/uri.svg)
[](https://img.shields.io/github/languages/code-size/kusabi/uri.svg)An implementation of a [PSR-7](https://www.php-fig.org/psr/psr-7/) & [PSR-17](https://www.php-fig.org/psr/psr-17/) conforming Uri library
## Installation
Installation is simple using composer.
```bash
composer require kusabi/uri
```Or simply add it to your `composer.json` file
```json
{
"require": {
"kusabi/uri": "^1.0"
}
}
```## Using the Uri class
The Uri class is a very basic wrapper around a Uri string.
```php
use Kusabi\Uri\Uri;// Instantiate a Uri instance
$uri = new Uri('https://user:pass@www.my-site.com:8080/users/22?filter=name#bottom');// Fetch the properties of the Uri instance
echo $uri->getScheme();
echo $uri->getAuthority();
echo $uri->getUserInfo();
echo $uri->getHost();
echo $uri->getPort();
echo $uri->getPath();
echo $uri->getQuery();
echo $uri->getFragment();
```## Using the Uri factory
The Uri factory can be used to create the Uri instance too.
```php
use Kusabi\Uri\UriFactory;// Instantiate a Uri instance
$factory = new UriFactory();
$uri = $factory->createUri('https://user:pass@www.my-site.com:8080/users/22?filter=name#bottom');// Fetch the properties of the Uri instance
echo $uri->getScheme();
echo $uri->getAuthority();
echo $uri->getUserInfo();
echo $uri->getHost();
echo $uri->getPort();
echo $uri->getPath();
echo $uri->getQuery();
echo $uri->getFragment();
```