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.
https://example.com vs. example.com) for features like:
http:///https:// for consistency in analytics).example.com to www.example.com).DomainName::when($isSecure, fn() => 'https://')->parse()) for:
a.example.com or b.example.com based on conditions).tenant1.yourservice.com with runtime subdomain generation).*.private.corp) critical for:
*.localhost or *.test without conflicts).*.corp, *.localhost) and need wildcard subdomain support.whois.xml).parse_url() + custom logic).rubix/ml-idn).For Executives: *"The latest update (6.4.0) supercharges this package for absolute domain handling and private/internal domains, enabling us to:
http:// vs. https://).*.private.corp) without custom code.For Engineering: *"6.4.0 adds critical features for absolute domains and private suffixes, with zero breaking changes (except a required PSL cache refresh):
withRootLabel()/withoutRootLabel(): Strip/add http:///https:// for URL normalization.isAbsolute(): Validate full URLs (e.g., reject example.com if you need https://example.com).when(): Build domains conditionally (e.g., DomainName::when($isSecure)->parse()).https://example.com).*.private.corp) work with wildcard subdomains.composer update jeremykendall/php-domain-parser
php artisan domain-parser:refresh # Laravel-specific; adjust for raw PHP
Use Cases:
parse_url() + regex for HTTPS enforcement in forms.tenant1.yourservice.com).when($isAdmin)->subdomain('admin')).
Trade-offs:composer.json and use DomainName::parse($url)->isAbsolute() in validation middleware or when() for dynamic domains."*How can I help you explore Laravel packages today?