league/uri
League URI is a PHP 8.1+ library with intuitive classes for parsing, validating, normalizing, and manipulating URIs. Supports PSR-7 integration plus optional IDN, IPv4 conversion, and HTML/DOM features when extensions are available.
uri-interfaces 7.8.1VariableBag implementationBuilder classBackedEnumtransform method to Uri and UrnUri::frombaseUri method 175Uri::isIpv4Host tells whether the URI host is an IPv4 addressUri::isIpv6Host tells whether the URI host is an IPv6 addressUri::isIpvFutureHost tells whether the URI host is an IPvFuture addressUri::isRegisteredNameHost tells whether the URI host is a registered nameUri::isDomainHost tells whether the URI host is a domain nameBaseUri::isSameDocument method 165HostRecord class, some registered name were wrongly throwing exceptions.Uri::withPath improve handling of path leading slash presenceUriTemplate::exapndToUrl and UriTemplate::expandToUrlOrFail adding the missing softErrors argument populated by reference.League\Uri\Urn object to specifically work with URN as defined by RFC8141Http::tryNew returns a new Uri instance on success or null on failure (ie: a Relax version of Http::new).Http::when conditional method to ease component building logic.Uri::parse returns a new Uri instance on success or null on failure (ie: a Relax version of Uri::fromBaseUri and Uri::new) that mimics the behaviour of the upcoming native PHP URI parse method.Uri::tryNew returns a new Uri instance on success or null on failure (ie: a Relax version of Uri::new).Uri::when conditional method to ease component building logic.Uri::isOpaque tells whether the URI is opaque or not.Uri::isAbsolute tells whether the URI is absolute or not.Uri::isNetworkPath tells whether the URI is a network path.Uri::isAbsolutePath tells whether the URI is an absolute path.Uri::isRelativePath tells whether the URI is a relative path.Uri::isSameDocument tells whether both URIs refer to the same document.Uri::equals tells whether both URIs refer to the same document (allows taking into account the fragment component)Uri::isLocalFile tells whether the file scheme base URI represents a local file.Uri::isCrossOrigin tells whether two URI do not share the same origin.Uri::isSameOrigin tells whether two URI share the same origin.Uri::getOrigin returns the URI origin as described in the WHATWG URL Living standard specification.Uri::toDisplayString returns the human-readable string representation of the URI as an IRI.Uri::toRfc8089 The method will return null if the URI scheme is not the file schemeUri::resolve returns a new Uri instance resolve against the current instance.Uri::normalize returns a new Uri instance with a full “normalized-decoded” representation: The URI is normalized (when applicable), and components are percent-decoded. Normalization may contain destructive operation.Uri::withUsername returns a new Uri instance with the updated username component.Uri::withPassword returns a new Uri instance with the updated password component.Uri::toAsciiString returns the URI string representation as per RFC3986Uri::toAsciiString returns the URI string representation as per RFC3987 with the host in Unicode form if availableUri::getUnicodeHost returns the host in Unicode form if available; fallback to its RFC3986 representation otherwiseUriTemplate implements the Stringable interfaceUriTemplate::expandToUri and UriTemplate::expandToUriOrFailUriTemplate::expandToUrl and UriTemplate::expandToUrlOrFailUriTemplate::expandToPsr7Uri and UriTemplate::expandToPsr7UriOrFailUriTemplate::expand and UriTemplate::expandOrFail take a second optional parameter which represents a base URI to resolve the URI from.psr/http-factory package which is required for the package.Uri\Rfc3986\Uri and Uri\Whatwg\UrlUserInfo now can be constructed and mutated even when the user component is not present. It was silently ignored.Uri and Http normalization normalized IP against RFC3986 rules and not WHATWG rules.Uri::getOrigin now follows WHATWG cross-origin definitionUri host encoding compliance to RFC3986 is improved by supporting RFC3986 encoded URI properlyUri parsing with strings started or ended with empty string are no longer allowedUri space are rawurlencoded.Uri validates urn as per RFC 8141Uri validates mailto scheme as per RFC 6068Uri validates blob scheme as per Blob DefinitionUri::getPath no longer trim the leading slashes (the Http class which is a PSR-7 compliant class still do!)BasUri use the Uri class or the uri-component Modifier class depending on your requirements.Uri::getUsername returns the encoded user component of the URI.Uri::getPassword returns the encoded password component of the URI.BaseUri::isOpaque tells whether a URI is opaque.Deprecated attribute to signal deprecated public API methods and constants.Http class implementation.BaseUri::from will compress the IPv6 host to its compressed form if possible.UriFactoryInterface is deprecated in BaseUri classUri::fromDataUri::fromRfc8089BaseUri::unixPathBaseUri::windowsPathBaseUri::toRfc8089composer.json constraintsBasUri::hasIDNEncoder class to normalize encoding and decoding in all packagesLeague\Uri\Uri::newLeague\Uri\Uri::fromComponentsLeague\Uri\Uri::fromServerLeague\Uri\Uri::fromWindowsPathLeague\Uri\Uri::fromUnixPathLeague\Uri\Uri::fromFileContentsLeague\Uri\Uri::fromClientLeague\Uri\Uri::fromTemplateLeague\Uri\Http::newLeague\Uri\Http::fromComponentsLeague\Uri\Http::fromBaseUriLeague\Uri\Http::fromServerLeague\Uri\Http::fromTemplateLeague\Uri\UriTemplate::expandOrFailLeague\Uri\UriTemplate\Template::expandOrFailLeague\Uri\UriTemplate\TemplateCanNotBeExpandedLeague\Uri\UriString::parseAuthorityLeague\Uri\UriString::buildAuthorityLeague\Uri\BaseUriLeague\Uri\UriInfo uri input now supports Stringable and string type.League\Uri\UriTemplate\VariableBag implements the IteratorAggregate interfaceLeague\Uri\UriTemplate\Operator to improve internal representation when using UriTemplate features.League\Uri\UriResolver use League\Uri\BaseUri insteadLeague\Uri\Uri::createFromString use League\Uri\Uri::newLeague\Uri\Uri::createFromUri use League\Uri\Uri::newLeague\Uri\Uri::createFromComponents use League\Uri\Uri::fromComponentsLeague\Uri\Uri::createFromBaseUri use League\Uri\Uri::fromBaseUriLeague\Uri\Uri::createFromServer use League\Uri\Uri::fromServerLeague\Uri\Uri::createFromWindowsPath use League\Uri\Uri::fromWindowsPathLeague\Uri\Uri::createFromUnixPath use League\Uri\Uri::fromUnixPathLeague\Uri\Uri::createFromDataPath use League\Uri\Uri::fromFileContentsLeague\Uri\Http::createFromString use League\Uri\Http::newLeague\Uri\Http::createFromUri use League\Uri\Http::newLeague\Uri\Http::createFromComponents use League\Uri\Http::fromComponentsLeague\Uri\Http::createFromBaseUri use League\Uri\Http::fromBaseUriLeague\Uri\Http::createFromServer use League\Uri\Http::fromServerLeague\Uri\UriTemplate\Template::createFromString use League\Uri\UriTemplate\Template::new__set_state__debugInfoLeague\Uri\UriTemplate\VariableBag::allLeague\Uri\Exceptions\TemplateCanNotBeExpanded use League\Uri\UriTemplate\TemplateCanNotBeExpanded insteadLeague\Uri\UriString class. Class moved to the uri-interfaces package.SensitiveParameter attributes to user information componentTemplate resolutionUriInterface::getPath value in the context of multiple leading slash characters.Http::getPath and Uri::getPath methods returned values are normalized to prevent potential XSS and open redirect vectors.UriInfo::isCrossOrigin method is fix to make it work with any PSR-7 compliant object 205UriInfo::isCrossOrigin methodTypeError to InvalidArgumentException to align with other UriInterface PSR-7 implementations.Uri::toString as a clean method to return URI string representation.IDNA conversion in now normalize using the Uri-Interface package classesUriInfo::getOrigin to returns the URI origin as described in the WHATWG URL Living standard specificationUriTemplate\Template, UriTemplate\Expression, UriTemplate\VarSpecifier, UriTemplate\VariableBag to
improve UriTemplate implementation.UriTemplate complete rewrite by reducing deep nested array usage.Uri::withScheme Uri validation failed to catch the empty string as an invalid scheme. #171UriTemplate::expand to comply with expansion rules for undefined variables #161 thanks Gabe Sulliceext-mbstring and the ext-fileinfo PHP extensions #154 thanks Nicolas GrekasLeague\Uri\UriTemplate variables validation and normalization improvedUri should not depend on intl extension if the host is in its ascii form #141League\Uri\UriInfo: to get RFC3986 information from an URI objectLeague\Uri\UriResolver: to resolve or relativize an URI objectLeague\Uri\UriString: to parse or build an URL into or from its componentsLeague\Uri\Uri::createFromBaseUri named constructorLeague\Uri\Uri::createFromDataPath named constructorLeague\Uri\Uri::createFromPsr7 named constructorLeague\Uri\Uri::createFromUnixPath named constructorLeague\Uri\Uri::createFromWindowsPath named constructorLeague\Uri\Http::createFromBaseUri named constructorLeague\Uri\Uri implements the JsonSerializable interfaceLeague\Uri\Http implements the JsonSerializable interfacecreate function defined in the League\Uri namespace replaced by League\Uri\Uri::createFromBaseUriLeague\Uri\Factory replaced by League\Uri\UriLeague\Uri\Data replaced by League\Uri\UriLeague\Uri\File replaced by League\Uri\UriLeague\Uri\Ftp replaced by League\Uri\UriLeague\Uri\Ws replaced by League\Uri\UriLeague\Uri\UriException replaced by League\Uri\Contract\UriExceptionLeague\Uri\AbstractUri internal, replaced by League\Uri\UriLeague\Uri\Schemes namespace and all classes insideLeague\Uri\Uri no longer implements League\Uri\UriInterfaceSee packages release notes for more informations
mbstring extension requirementThe library is now a metapackage, you can read the migration guide for upgrading or the complete documentation for the new version.
Component::getContent returns the raw encoded representation of a componentComponent::withContent to create a new instance from a given raw encoded contentgetDecoded method to access the decoded content for the following classes:
UserPassFragment__debugInfo and __set_state to improve debuggingModifiers\RelativizeModifiers\DecodeUnreservedCharactersPath::createFromSegmentsPath::getSegmentsHost::createFromLabelsHost::getLabelsQuery::createFromPairsQuery::getPairsModifiers\uri_reference function to return URI reference state.Host::getRegisterableDomain must always return a string as per the host interface expected return typeHost::getSubdomain must always return a string as per the host interface expected return typeHost::isPublicSuffixValid when no publicSuffix information is foundHost::isPublicSuffixValid must always return a string as per the host interface expected return typecreateFromComponents failing with parse_url result when no path is definedInvalidArgumentException exceptions are emitted instead of RuntimeException ones to normalize exception to PSR-7Modifiers\Normalize class removes dot segments only on URI with absolute path.Modifiers\Normalize class decode all unreserved characters.Ftp and Ws objects now accept relative reference URI without the scheme.Component::modify use Component::withContent insteadHost::getLiteralPort::toInt use Port::getContent insteadHierarchicalPath::createFromArray use HierarchicalPath::createFromSegments insteadHierarchicalPath::toArray use HierarchicalPath::getSegments insteadHost::createFromArray use Host::createFromLabels insteadHost::toArray use Host::getLabels insteadQuery::createFromArray use Query::createFromPairs insteadQuery::toArray use Query::getPairs insteadUriPart::sameValueAsFormatter::preserveQuery to improve query inclusion in URI string representationFormatter::preserveFragment to improve fragment inclusion in URI string representationFormatter::__invoke as an alias of Formatter::formatUriParser::__invoke as an alias of UriParser::parseFormatter::getHostEncodingFormatter::getQueryEncodingFormatter::getQuerySeparatorModifiers\Filters\Flag::withFlagsModifiers\Filters\ForCallbable::withCallableModifiers\Filters\ForCallbable::withCallableModifiers\Filters\Keys::withKeysModifiers\Filters\Label::withLabelModifiers\Filters\Offset::withOffsetModifiers\Filters\QueryString::withQueryModifiers\Filters\Segment::withSegmentModifiers\Filters\Uri::withUriModifiers\DataUriParameters\withParametersModifiers\Extension\withExtensionModifiers\KsortQuery\withAlgorithmModifiers\Typecode\withTypeUser and Pass encodingHttp::createFromServer handling userinfo when not using mod_php with $_SERVER['HTTP_AUTHORIZATION']UriParser handling URI strings with invalid schemeQueryParser handling numeric index issue #25DataPath mimetype syntax validation issue #21DataPath::withParameters the ;base64 binary code now always throw an InvalidArgumentExceptionIntl extension is now required to use the libraryFileInfo extension is now required to use the libraryHost using jeremykendall/php-domain-parser packageUriParser to parse an URI according to RFC3986 rulesQueryParser to parse and build a query string according to RFC3986 rules.League\Uri\Schemes\Generic\AbstractUri to enable better URI extensionData class to specifically manipulate data schemed URIHttp class to specifically manipulate http,https schemed URIFtp class to specifically manipulate ftp schemed URIWs class to specifically manipulate ws, wss schemed URIDataPath component class to manipulate Data-uri path componentHierarchicalPath to manipulate Hierarchical-like path componentLeague\Url to League\Uri to avoid dependency hellRFC3986PHP 5.4 and PHP 5.3parse_url, parse_str and http_build_query functionsTrue/php-punycode libraryLeague\Url\Url, League\Url\UrlImmutable, League\Url\UrlConstants classesHow can I help you explore Laravel packages today?