Logo
URI toolkit

The URI toolkit
For PHP Developers

A complete PHP toolkit for working with URIs. Parse, validate, format, and manipulate any RFC 3986 or RFC 8141–compliant identifier in a consistent, standards-based way. Aligned with the WHATWG URL Living Standard. Includes polyfills, PSR-7 and PSR-17 adapters, and modern replacements for PHP’s legacy URL functions.

use League\Uri\Components\Query;
use League\Uri\Modifier;
use League\Uri\Uri;

$uri = Uri::new('https://example.com?q=value#fragment');
$uri->getScheme(); // returns 'http'
$uri->getHost();   // returns 'example.com'

$newUri = Modifier::wrap($uri)->appendQuery('q=new.Value');
echo $newUri; // 'https://example.com?q=value&q=new.Value#fragment'

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