Skip to content
/ uri Public

A PSR-7 and PSR-17 conforming uri library for PHP

License

Notifications You must be signed in to change notification settings

kusabi/uri

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Uri wrapper

Tests codecov Licence Badge Release Badge Tag Badge Issues Badge Code Size

An implementation of a PSR-7 & PSR-17 conforming Uri library

Installation

Installation is simple using composer.

composer require kusabi/uri

Or simply add it to your composer.json file

{
    "require": {
        "kusabi/uri": "^1.0"
    }
}

Using the Uri class

The Uri class is a very basic wrapper around a Uri string.

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.

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();

About

A PSR-7 and PSR-17 conforming uri library for PHP

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages