定制 bentools/hostname-extractor 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bentools/hostname-extractor

最新稳定版本:1.3

Composer 安装命令:

composer require bentools/hostname-extractor

包简介

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

README 文档

README

Latest Stable Version License Build Status Coverage Status Quality Score Total Downloads

Hostname Extractor

A simple library to manipulate domains.

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).

The library parses the Public Suffix List, which stores thousands of existing suffixes.

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.

Installation

PHP 7.1+ with mbstring extension is required.

composer require bentools/hostname-extractor ^1.0

Tests

./vendor/bin/phpunit

License

MIT.

See also

bentools/querystring - Easily manipulate your query strings.

bentools/uri-factory - PSR-7 UriInterface factory with multiple libaries support.

统计信息

  • 总下载量: 567
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-08