bakame / aide-uri
URI polyfill for PHP native RFC3986/WHATWG URI classes
Fund package maintenance!
nyamsprod
Requires
- php: ^8.1
- league/uri-interfaces: dev-master
- rowbot/url: ^4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75.0
- phpbench/phpbench: ^1.4.1
- phpstan/phpstan: ^2.1.13
- phpstan/phpstan-deprecation-rules: ^2.0.2
- phpstan/phpstan-phpunit: ^2.0.6
- phpstan/phpstan-strict-rules: ^2.0.4
- phpunit/phpunit: ^10.5.45 || ^11.5.7 || ^12.1.3
- symfony/var-dumper: ^v6.4.18 || ^v7.2.3
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:
- PHP >= 8.1 but the latest stable version of PHP is recommended
- League URI Interfaces and its dependencies
- URL-Parser and its dependencies
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:
- a PHPUnit test suite
- a code analysis compliance test suite using PHPStan.
- a coding style compliance test suite using PHP CS Fixer.
- a benchmark using PHP Bench.
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.