PHP code example of cyberfusion / domain-parser

1. Go to this page and download the library: Download cyberfusion/domain-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cyberfusion / domain-parser example snippets


use Cyberfusion\DomainParser\Parser;

$parser = new Parser();
$parsedDomain = $parser->domain('www.cyberfusion.nl');

$parsedDomain->getRegistrableDomain(); // cyberfusion.nl
$parsedDomain->getSld(); // cyberfusion
$parsedDomain->getTld(); // nl
$parsedDomain->hasSubdomain(): // true
$parsedDomain->getSubdomain(); // www
$parsedDomain->isApexDomain(); // false
$parsedDomain->getFqdn(); // www.cyberfusion.nl

$parser = new Parser(provider: new PublicSuffixList());

$parser = new Parser(provider: new IANATopLevelDomainList());

$parser = new Parser(
    cache: Cache::store(),
    provider: new PublicSuffixList()
);