URI

Modern API to process URI in PHP.

Once a new major version is released, the previous stable release remains supported for six more months through patches and security fixes.

Intuitive

use League\Uri\Components\Query;
use League\Uri\Uri;
use League\Uri\UriModifier;

$uri = Uri::createFromString('http://example.com?q=value#fragment');
$newUri = UriModifier::appendQuery($uri, 'q=new.Value');
echo $newUri; // 'http://example.com?q=value&q=new.Value#fragment';

$query = Query::createFromUri($newUri);
$query->get('q');    // returns 'value'
$query->getAll('q'); // returns ['value', 'new.Value']
$query->params('q'); // returns 'new.Value'

The libraries manipulate URIs and their components using a simple yet expressive code.

Highlights

This suite of packages provides simple and intuitive classes to parse, validate, format and manipulate URIs and their components. It is built to enable working with any kind of RFC3986 compliant URI and also follow closely the latest WHATG Living standard specification.

  1. Simple and extensible API

  2. RFC3986 compliant

  3. follows URL Living Standard specifications

  4. Implements PSR-7 UriInterface interface

  5. Framework-agnostic

Packages

building blocks

uri
This is the main package. It's goal is to ease generating and manipulation a full URI object independently from the URI schemes.
uri-components
This package complement the URI package by providing a object oriented way to access and manipulate each URI components. It can be use to partially update such component in a full URI object context.

Deprecated blocks

uri-schemes
Collection of URI objects. This package is deprecated because it conflicts and is superseded by the latest URI object package.
uri-manipulations
Functions and Middleware to ease URI Objects manipulations. This package is deprecated because it is superseded by the latest URI component object package.
uri-hostname-parser
A lightweight public suffix list ICANN section parser. This package is deprecated as it was a temporary solution which is superseeded by other PHP packages dedicated to domain host parsing.

Helpers blocks

While no longer updated the following helper packages will continue to receive patch fixes as long as PHP7 is maintained. Their features are back-ported into maintained packages without BC break. Avoid using them for new projects.

uri-parser
a PHP user land RFC3986 compliant parser and builder to turn any valid URI string into an array and to build an URI out of a given array.
uri-query-parser
modern URI query string parser and builder based on RFC3986 and the URL Living Standard.

Questions?

The packages were created by Ignace Nyamagana Butera. Find him on Twitter at @nyamsprod.