bakame/aide-uri

Polyfill backporting PHP 8.5+ native RFC3986/WHATWG URI features to lower PHP versions

Fund package maintenance!
nyamsprod

dev-main 2025-05-18 21:23 UTC

This package is auto-updated.

Last update: 2025-05-18 21:23:47 UTC


README

$uri = new Uri\Rfc3986\Uri("HTTPS://ex%61mpLE.com:443/foo/../bar/./baz?#fragment");
$uri->toRawString(); // returns "HTTPS://ex%61mpLE.com:443/foo/../bar/./baz?#fragment"
$uri->toString();    // returns "https://example.com:443/bar/baz?#fragment"

$url = new Uri\WhatWg\Url("HTTPS://🐘.com:443/foo/../bar/./baz?#fragment");
echo $url->toAsciiString();   // returns "https://xn--go8h.com/bar/baz?#fragment"
echo $url->toUnicodeString(); // returns "https://🐘.com/bar/baz?#fragment"

This package provides a polyfill for PHP version greater or equal to PHP8.1 to the new native PHP URI parsing features in voting phase to be included in PHP8.5.

System Requirements

To use the package, you require:

Tip

If you are using PHP 8.1, you SHOULD install symfony/polyfill-php82 to use its SensitiveParameter polyfill

Install

Install the package using Composer.

composer require bakame/aide-uri:dev-main

Documentation

The RFC introduces:

  • the Uri\Rfc3986\Uri class, an RFC 3986 compliant URI parser
  • the Uri\WhatWg\Url class, an WHATWG compliant URL parser

Full documentation can be found on the Add RFC 3986 and WHATWG compliant URI parsing support RFC.

Testing

The package has:

To run the tests, run the following command from the project root folder.

composer test

You can run the benchmark separately using the following command:

composer benchmark

Contributing

Contributions are welcome and will be fully credited. Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email nyamsprod@gmail.com instead of using the issue tracker.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see LICENSE for more information.