bakame/aide-uri

URI polyfill for PHP native RFC3986/WHATWG URI classes

Fund package maintenance!
nyamsprod

dev-main 2025-05-04 07:37 UTC

This package is auto-updated.

Last update: 2025-05-04 08:52:27 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 "http://example.com:443/bar/baz?#fragment"

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

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

The RFC introduces:

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

System Requirements

To use the package you are required to use:

Install

Install aidre-uri using Composer.

composer require bakame/aide-uri:dev-main

Documentation

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

Testing

The URI polyfill has:

To run the tests, run the following command from the project 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.