2017 © Pedro Peláez
 

library hostname-extractor

Hostname extractor - A library to find parts of a hostname (suffix, tld, subdomain, ...)

image

bentools/hostname-extractor

Hostname extractor - A library to find parts of a hostname (suffix, tld, subdomain, ...)

  • Wednesday, June 27, 2018
  • by bpolaszek
  • Repository
  • 1 Watchers
  • 0 Stars
  • 51 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 31 % Grown

The README.md

Latest Stable Version License Build Status Coverage Status Quality Score Total Downloads, (*1)

Hostname Extractor

A simple library to manipulate domains., (*2)

Usage

require_once __DIR__ . '/vendor/autoload.php';

use BenTools\HostnameExtractor\HostnameExtractor;
use BenTools\HostnameExtractor\SuffixProvider\PublicSuffixProvider;

$extractor = new HostnameExtractor(new PublicSuffixProvider());
$hostname = $extractor->extract('my.preferred.domain.co.uk');
dump($hostname->getSubdomain()); // my.preferred
dump($hostname->getDomain()); // domain
dump($hostname->getSuffix()); // co.uk
dump($hostname->getTld()); // uk
dump($hostname->getSuffixedDomain()); // domain.co.uk
dump($hostname->isIp()); // false
dump($hostname->isIpv4()); // false
dump($hostname->isIpv6()); // false

As you can see, co.uk is considered as a suffix (otherwise, we would have considered that co is the domain and uk the suffix / tld)., (*3)

The library parses the Public Suffix List, which stores thousands of existing suffixes., (*4)

To avoid network latency feel free to implement your own BenTools\HostnameExtractor\SuffixProvider\SuffixProviderInterface or to use your favorite PSR-16 library into a BenTools\HostnameExtractor\SuffixProvider\PSR16CacheSuffixProvider object., (*5)

Installation

PHP 7.1+ with mbstring extension is required., (*6)

composer require bentools/hostname-extractor ^1.0, (*7)

Tests

./vendor/bin/phpunit, (*8)

License

MIT., (*9)

See also

bentools/querystring - Easily manipulate your query strings., (*10)

bentools/uri-factory - PSR-7 UriInterface factory with multiple libaries support., (*11)

The Versions

27/06 2018

dev-master

9999999-dev

Hostname extractor - A library to find parts of a hostname (suffix, tld, subdomain, ...)

  Sources   Download

MIT

The Requires

 

The Development Requires

url domain extractor uri subdomain tld suffix host hostname

11/12 2017
08/12 2017