All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- New
*OrThrow()methods in theValidatorclass that throw anInvalidUrlComponentExceptionon invalid values, complementing the existing methods which returnnull(e.g.Validator::schemeOrThrow(),Validator::userOrThrow(),Validator::passwordOrThrow(),Validator::hostOrThrow(),Validator::pathOrThrow(), etc.).
- Potential issues found with PHPStan 2 on level 8.
- Updated lists of public suffixes, schemes and default ports.
Validator::callValidationByComponentName()– This method dynamically dispatches to component-specific validation methods (e.g.callValidationByComponentName('scheme', 'https')=>Validator::scheme('https')) and is no longer needed. Call the corresponding validation method directly instead (e.g.Validator::scheme()).
- Improvement for PHP 8.4.
- Update schemes and suffixes lists.
- Update schemes and suffixes lists.
- An issue in the Validator, when trying to validate an absolute input URL that contains non ASCII characters.
- Method
toPsr7()to conveniently get a PSR-7 compatible instance from anUrlinstance. Basically wrapper fornew Uri($urlInstance).
- Issue with resolving relative URLs.
- Update schemes and suffixes lists.
- Support psr/http-message v2.0.
- As there is the new query string package, replace the last usage of the
Helpers::queryStringToArray()method with theQueryclass from the package, to not have duplicate logic. Also, the package already contains some fixes.
- Updated lists of schemes, suffixes and default ports.
- When a URL doesn't contain a subdomain part, the
subdomain()method returnsnull.
- BREAKING: Removed access to URL components (scheme, host, path,...) via magic class properties (
$this->scheme,$this->host,...). Use method calls instead ($this->scheme(),$this->host(),...).
- Required PHP version is now 8.0.
- Updated schemes and suffixes lists.
- As the PHP version requirement allows it now, the
crwlr/query-stringpackage now is a dependency of this package and doesn't have to be required separately anymore in order for theUrl::queryString()method to work.
- The new
queryString()method can be used to access and manipulate the query via aQueryobject when thecrwlr/query-stringpackage is installed.
- Update schemes and suffixes lists.
- Resolving relative paths without leading slash against a base URL with an empty path.
- Update schemes and suffixes lists.
- Static method to create PSR-7
Uriobject (Url::parsePsr7('https://...')).
- Error when resolving something to a URL with an empty path.
- Run tests also on PHP 8.1 in CI.
- Update schemes and suffixes lists.
- Support for PHP 8.0
- Minor change in Validator because output of PHP's parse_url is different when a URL includes a delimiter for query or fragment but has no actual query or fragment (followed by empty string).
- Change PHP version requirement in composer.json.
- Only relevant for development: Temporarily add
PHP_CS_FIXER_IGNORE_ENV=1 to
composer cscommand until PHP Coding Standards Fixer fully supports PHP 8.0.
- Getting standard ports for schemes on systems where /etc/services file is missing. PHP's getservbyname() function uses that file and when it's missing the function returns false for all schemes. Fixed that by having a list within the package.
- Adapter class
Urithat implements the PSR-7UriInterface. - New methods in
Urlclass:authority: Get or set the full authority part of the URL.userInfo: Get or set the full userInfo part of the URL.isRelativeReference: Returns true when the current URL is a relative reference.hasIdn: Returns true when the current URL contains an internationalized domain name in the host component.isEqualTo: Compare the current URL to another one.isComponentEqualIn: Compare some component of the current URL to the same component in another URL. Also with separate methods for all available components:isSchemeEqualInisAuthorityEqualInisUserEqualInisPasswordEqualInisUserInfoEqualInisHostEqualInisDomainEqualInisDomainLabelEqualInisDomainSuffixEqualInisSubdomainEqualInisPortEqualInisPathEqualInisQueryEqualInisFragmentEqualIn
- New static validation methods in
Validator:authorityauthorityComponentsuserInfouserInfoComponentsuserpassword(alias methodpass)domainLabelcallValidationByComponentName
- Extracted parsing the host part (and registrable domain if
contained) to separate classes
HostandDomain. - New class
Helperswith some static helper methods that are used in multiple several classes. Also static access to instances of classesSuffixesandSchemes. - New
InvalidUrlComponentExceptionthat is thrown when you're trying to set an invalid new value for some component.
- Required PHP version is now 7.2 because PHP 7.0 and 7.1 are no longer actively supported.
- Instances of the
Urlclass can now be created from relative references (without scheme). In v0.1 creating a new instance from a relative reference threw an Exception. If your application expects this behavior, you can use theisRelativeReferencemethod of theUrlobject to find out if the URL in question is a relative reference. - All methods in
Validatorare now static and all the component validation methods (scheme, host,...) now returnnullinstead offalsefor invalid values. Further Validating a full URL was split into 4 different methods:url: Returns the validated URL as string if input is valid (nullif invalid).urlAndComponents: Returns an array with validated URL as string and all single validated URL components (nullif invalid).absoluteUrl: Same asurlbut only absolute URLs are considered valid.absoluteUrlAndComponents: Same asurlAndComponentsbut only absolute URLs are valid.
- Switch to
idn_to_asciiandidn_to_utf8(respectively symfony/polyfill-intl-idn ) to handle parse internationalized domain names. InvalidUrlExceptionnow extendsUnexpectedValueExceptioninstead ofException.- Class
Storeis now abstract.
- Method
compareinUrl. UseisEqualToor the other new comparison methods listed under "Added" above. - Class
Parser. Most still needed code is moved toHelpersclass. - Move static method
getStandardPortBySchemefrom classUrlto classHelpers. - Method
userOrPasswordinValidator. Use methodsuserorpassword(pass) instead.
- Version 0.1 had an issue that path, query or fragment could
have been double encoded in some cases. This shouldn't
happen anymore (see method
encodePercentCharacterinValidator).