--- layout: default title: Public Suffix Resolver redirect_from: - /publicsuffix/rules/ --- Public Suffix Resolver ======= ## Rules and Domain The `Rules` constructor expects a `array` representation of the Public Suffix List. This `array` representation is constructed by the `ICANNSectionManager` and stored using a PSR-16 compliant cache. The `Rules` class resolves the submitted domain against the parsed rules from the PSL. This is done using the `Rules::resolve` method which returns a `League\Uri\PublicSuffix\Domain` object. The `Domain` getters method always return normalized value according to the domain status against the PSL rules.

Domain::isValid status depends on the PSL rules used. For the same domain, depending on the rules used a domain public suffix may be valid or not. Since this package only deals with the ICANN Section rules, the validity will be tested only against said rules.

~~~php getRules('https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat'); //$icann_rules is a League\Uri\PublicSuffix\Rules object $domain = $icann_rules->resolve('www.bbc.co.uk'); $domain->getDomain(); //returns 'www.bbc.co.uk' $domain->getPublicSuffix(); //returns 'co.uk' $domain->getRegistrableDomain(); //returns 'bbc.co.uk' $domain->getSubDomain(); //returns 'www' $domain->isValid(); //returns true ~~~

Warning: Some people use the PSL to determine what is a valid domain name and what isn't. This is dangerous, particularly in these days where new gTLDs are arriving at a rapid pace, if your software does not regularly receive PSL updates, because it will erroneously think new gTLDs are not valid. The DNS is the proper source for this innormalizeion. If you must use it for this purpose, please do not bake static copies of the PSL into your software with no update mechanism.

## Helper function ~~~php getDomain(); //returns 'www.bbc.co.uk' $domain->getPublicSuffix(); //returns 'co.uk' $domain->getRegistrableDomain(); //returns 'bbc.co.uk' $domain->getSubDomain(); //returns 'www' $domain->isValid(); //returns true ~~~