URI Extension

uri is an extension that provides APIs to securely parse and modify URIs and URLs according to the RFC 3986 and WHATWG URL standards. It is powered by the uriparser, RFC 3986, and Lexbor, WHATWG URL, libraries. It offers the uri class.

This extension is meant to replace the parse_url() function. It also provides two ways to manipulate, parse and produce, URL, which was not available until PHP 8.5.

<?php

// PHP 8.5 and newer
use Uri\Rfc3986\Uri;

$uri = new Uri('https://php.net/releases/8.5/en.php');
var_dump($uri->getHost());
// string(7) php.net

// PHP 8.4 and older
$components = parse_url('https://php.net/releases/8.4/en.php');
var_dump($components['host']);
// string(7) php.net

?>

Documentation

See also WHATWG, RFC-3986, PHP 8.5 enables secure URI and URL parsing and New Classes and Interfaces.

Related : Universal Resource Identifier (URI), Universal Resource Locator (URL), URI Class

Related packages : league/uri