domainvalidity/php-domain-validator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

domainvalidity/php-domain-validator

Composer 安装命令:

composer require domainvalidity/php-domain-validator

包简介

Light PHP package to validate domains.

README 文档

README

Doma(in)Validity PHP package

Light PHP package to validate domains using the Mozilla Public Suffix List.

Doma(in)Validity was born because the usual "validate a domain" regex grows new edge cases every time you look away — multi-level TLDs (co.uk, com.mx), IDN labels, private suffixes (*.amazonaws.com). This package outsources the hard part to the PSL.

Requirements

  • PHP >= 8.2.0 (for v3.x)
  • PHP >= 8.1.0 (for v2.x)

Installation

composer require domainvalidity/php-domain-validator

Quick start

use DomainValidity\Factory;

$psl       = file_get_contents('path/to/public_suffix_list.dat');
$validator = Factory::make($psl);

$host = $validator->validate('www.domainvalidity.dev');

$host->isValid();   // true
$host->tld();       // 'dev'
$host->domain();    // 'domainvalidity.dev'
$host->toString();  // 'www.domainvalidity.dev'

Cache the Public Suffix List and refresh at most once per day. It is updated only a few times per week, so more frequent fetching is wasteful. See the usage guide below for a secure, cached fetch pattern.

Documentation

  • docs/USAGE.md — full usage guide, secure PSL fetching, caching strategy, complete API reference, worked examples, and error-handling model.
  • SECURITY.md — supported versions and how to report vulnerabilities.
  • CHANGELOG.md — release history.

License

MIT — see LICENSE.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固