jeremykendall/php-domain-parser
Parse, validate, and normalize domains, subdomains, and suffixes using the Public Suffix List. Extract registrable domain vs. subdomain, handle IDNs and edge cases, and keep parsing rules current via PSL updates—ideal for URL processing, cookies, and security checks.
DomainName::withRootLabel, DomainName::withoutRootLabel, DomainName::isAbsolute methods to handle absolute domain names.DomainName::when to allow conditionable when building the domain.[!WARNING] When upgrading to version
6.4you MUST refresh your local cache for the fix on private domain resolution to take effect.
RegisteredName class to allow domain with IP4-like labelsDomain decorates the new RegisteredName class #347Host::withoutLabel works without arguments.Internal code to make services readonly
Internal code to make VO properties readonly
Internal code improved typehinting
None
Rules::getPrivateDomain is more restrictive It will throw if the domain name does not contain a valid "private" TLD.TimeToLive::untilTimeToLive::fromDurationString.gitattributes files to be filter out.TimeToLive marked as internalHost::toUnicode method MUST never throw exceptions on conversion according to RFC3490.UnableToResolveDomain typo in the exception messageTimeToLive::fromDateTimeInterface use TimeToLive::fromNowTimeToLive::fromScalar use TimeToLive::convertDomain::clear to easily initialize an empty domain objectDomain::slice to easily slice a domain objectResolvedDomain object to normalize Resolver results.Suffix object to replace the PublicSuffix object from v5.Idna, IDN support has been completely revampedStream class, to improve path/stream resolutionPdp\TopLevelDomains::getIANADomain which throws on syntax error and if no effective TLD is found (behave like Pdp\TopLevelDomains::resolve in v5).Pdp\Domain class not longer directly exposes Effective TLD status.Pdp\Rules::resolve and Pdp\TopLevelDomains::resolve) no longer accept IDNA options.Rules::getICANNDomain, Rules::getPrivateDomain will throw even if a PublicSuffix is found but does not belong to the correct PSL section.Pdp\TopLevelDomains::resolve acts like Pdp\Rules::resolve and only throw on TypeError__toString and __debugInfo usagebin/update-pslPdp\Cache, Pdp\CacheException: The package PSR-16 Cache implementation using the underlying filesystem.Pdp\HttpClient, Pdp\CurlHttpClient and Pdp\HttpClientException: The package Http Client.Pdp\Installer, Pdp\Manager: The package source manager and installerPdp\Logger, The package logger implementationPdp\Rules::ALL_DOMAINS constant deprecated in version 5.3Pdp\Domain::getDomain deprecated in version 5.3Pdp\Domain::resolvePdp\Domain::getPublicSuffix replaced by Pdp\ResolvedDomain::suffixPdp\Domain::getRegistrableDomain replaced by Pdp\ResolvedDomain::registrableDomainPdp\Domain::getSubDomain replaced by Pdp\ResolvedDomain::subDomainPdp\Domain::withPublicSuffix replaced by Pdp\ResolvedDomain::withSuffixPdp\Domain::getLabel replaced by Pdp\Domain::labelPdp\Domain::isTransitionalDifferent replaced by Pdp\IdnaInfo::isTransitionalDifferentPdp\PublicSuffix replaced by Pdp\SuffixPdp\Domain object is no longer possible you need to do it from Pdp\SuffixPdp\TopLevelDomains::contains without replacementRules::getCookieDomainRules::getICANNDomainRules::getPrivateDomainCouldNotResolvePublicSuffix::dueToUnresolvableDomainPublicSuffix::labels and Domain::labels to return the VO labels see #241IDNAConverterTrait::parse (internal)IDNAConverterTrait::setLabels replaced by IDNAConverterTrait::parse (internal)Pdp\TopLevelDomains to allow resolving domain againts IANA Root zone databasePdp\TLDConverter converts the IANA Root Zones database into an associative arrayPdp\Manager::getTLDs a service to return a cache version of the IANA Root zone databasePdp\Manager::refreshTLDs a service to refresh the cache version of the IANA Root zone database$ttl parameter to improve PSR-16 supports to
Pdp\Manager::__constructPdp\Manager::getRulesPdp\Manager::refreshRulesPdp\Exception\CouldNotLoadTLDs exceptionPdp\IDNAConverterTrait::setLabels improve IDN domain handlingPdp\IDNAConverterTrait throws a UnexpectedValueException if the Intl extension is misconfigured see #230Pdp\PublicSuffixListSection interface implemented by Pdp\Rules and Pdp\PublicSuffixPdp\DomainInterface interface implemented by Pdp\Domain and Pdp\PublicSuffixPdp\Domain::getContent replaces Pdp\Domain::getDomainPdp\Domain::withLabel adds a new label to the Pdp\Domain.Pdp\Domain::withoutLabel removes labels from the Pdp\Domain.Pdp\Domain::withPublicSuffix updates the Pdp\Domain public suffix part.Pdp\Domain::withSubDomain updates the Pdp\Domain sub domain part.Pdp\Domain::append appends a label to Pdp\Domain.Pdp\Domain::prepend prepends a label to Pdp\Domain.Pdp\Domain::resolve attach a public suffix to the Pdp\Domain.Pdp\Domain::isResolvable tells whether the current Pdp\Domain can have a public suffix attached to it or not.Pdp\PublicSuffix::createFromDomain returns a new Pdp\PublicSuffix object from a Pdp\DomainobjectPdp\Exception sub namespace to organize exception. All exception extends the Pdp\Exception class to prevent BC break.Pdp\Domain domain part computation (public suffix, registrable domain and sub domain)Pdp\Domain and Pdp\PublicSuffix host validation compliance to RFC improvedPdp\Converter and Pdp\Manager class to better report error on IDN conversion.Pdp\Installer vendor directory resolution see PR #222Pdp\Exception nows extends InvalidArgumentException instead of RuntimeExceptionPdp\Domain::getDomain use instead Pdp\Domain::getContentPdp\Rules::ALL_DOMAINS use the empty string insteadPdp\Rules::getPublicSuffix returns a Pdp\PublicSuffix value objectPdp\Rules::__set_state is implementedPdp\Domain::toUnicode returns a Pdp\Domain with its value converted to its Unicode formPdp\Domain::toAscii returns a Pdp\Domain with its value converted to its AScii formPdp\PublicSuffix::toUnicode returns a Pdp\PublicSuffix with its value converted to its Unicode formPdp\PublicSuffix::toAscii returns a Pdp\PublicSuffix with its value converted to its AScii formPdp\Domain::getDomain returns the normalized form of the domain namePdp\PublicSuffix is no longer internal.IDNConverterTraitPdp\Rules::createFromPath named constructor to returns a new instance from a pathPdp\Rules::createFromString named constructor to returns a new instance from a stringPdp\CurlHttpClient default curl options improvedPdp\Exception a base exception for the libraryPdp\Rules a class to resolve domain name against the public suffix listPdp\Domain an immutable value object to represents a parsed domain namePdp\Installer a class to enable improve PSL maintenancePdp\Cache a PSR-16 file cache implementation to cache a local copy of the PSLPdp\Manager a class to enable managing PSL sources and Rules objects creationPdp\Converter a class to convert the PSL into a PHP arrayPdp\PublicSuffixList class replaced by the Pdp\Rules classPdp\PublicSuffixManager class replaced by the Pdp\Manager classPdp\HttpAdapter\HttpAdapterInterface interface replaced by the Pdp\HttpClient interfacePdp\HttpAdapter\CurlHttpAdapter class replaced by the Pdp\CurlHttpClient classRelease to include all commits to master before new-new version (BC breaking v5). Totally pooched semantic versioning so v4 will be kind of an interim version. Apologies ☹️
IMPORTANT: These are all BC breaking changes (some more significant than others).
http scheme is no longer prepended to URLs which do not include schemes./bin/pdp-psl. to ./bin/update-pslcomposer.json to update the Public Suffix list when calling composer installparse_url() fix to pdp_parse_url() and supported PHP 5.3 versions: "Fixed host recognition when scheme is omitted and a leading component separator is present."bin/parsebin/parse to include suffix validityParser::mbParseUrl, a UTF-8 compatible version of PHP's parse_urlpdp_parse_url, a UTF-8 compatible version of PHP's parse_urlParser:: isSuffixValid to test validity of domain suffix (thanks to @SmellyFish)See https://github.com/jeremykendall/php-domain-parser/compare/1.4.6...2.0.0 for detailed version diff
Library now requires ext-intl and ext-mbstring.
Adds IPv6 support, courtesy of a bugfix submitted by @geekwright.
Documentation updates (removes TODO)
Adds "ext-mbstring" to composer require key
How can I help you explore Laravel packages today?