Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 4 days 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 (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2020-10-31T13:20:06.000Z (about 4 years ago)
- Last Synced: 2024-11-17T15:29:33.388Z (2 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
![Tests](https://github.com/kusabi/uri/workflows/tests/badge.svg)
[![codecov](https://codecov.io/gh/kusabi/uri/branch/main/graph/badge.svg)](https://codecov.io/gh/kusabi/uri)
[![Licence Badge](https://img.shields.io/github/license/kusabi/uri.svg)](https://img.shields.io/github/license/kusabi/uri.svg)
[![Release Badge](https://img.shields.io/github/release/kusabi/uri.svg)](https://img.shields.io/github/release/kusabi/uri.svg)
[![Tag Badge](https://img.shields.io/github/tag/kusabi/uri.svg)](https://img.shields.io/github/tag/kusabi/uri.svg)
[![Issues Badge](https://img.shields.io/github/issues/kusabi/uri.svg)](https://img.shields.io/github/issues/kusabi/uri.svg)
[![Code Size](https://img.shields.io/github/languages/code-size/kusabi/uri.svg?label=size)](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:[email protected]: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:[email protected]: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();
```