PHPackages                             domainvalidity/php-domain-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. domainvalidity/php-domain-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

domainvalidity/php-domain-validator
===================================

Light PHP package to validate domains.

3.0.1(2mo ago)312.0k↑114.3%1MITPHPPHP ^8.2.0

Since Jul 27Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/domainvalidity/php-domain-validator)[ Packagist](https://packagist.org/packages/domainvalidity/php-domain-validator)[ RSS](/packages/domainvalidity-php-domain-validator/feed)WikiDiscussions 3.x Synced today

READMEChangelog (10)Dependencies (10)Versions (18)Used By (0)

 [![](./.art/domainvalidity.png)](./.art/domainvalidity.png)

Doma(in)Validity PHP package
============================

[](#domainvalidity-php-package)

Light PHP package to validate domains using the Mozilla [Public Suffix List](https://publicsuffix.org/).

[Doma(in)Validity](https://api.domainvalidity.dev/) 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
------------

[](#requirements)

- PHP **&gt;= 8.2.0** (for v3.x)
- PHP **&gt;= 8.1.0** (for v2.x)

Installation
------------

[](#installation)

```
composer require domainvalidity/php-domain-validator
```

Quick start
-----------

[](#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
-------------

[](#documentation)

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

License
-------

[](#license)

MIT — see [`LICENSE`](LICENSE).

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance87

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 94.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~77 days

Recently: every ~196 days

Total

14

Last Release

63d ago

Major Versions

0.1.0 → 1.0.02023-07-27

1.0.2 → 2.0.02024-01-15

1.x-dev → 2.0.12024-01-24

2.x-dev → 3.0.02026-01-31

PHP version history (2 changes)0.1.0PHP ^8.1.0

3.0.0PHP ^8.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ba004d502228eb272341845427581da17399ec8b4315ce16c99b298ec0a414f?d=identicon)[adrorocker](/maintainers/adrorocker)

---

Top Contributors

[![adrorocker](https://avatars.githubusercontent.com/u/1872940?v=4)](https://github.com/adrorocker "adrorocker (51 commits)")[![rickycheers](https://avatars.githubusercontent.com/u/480247?v=4)](https://github.com/rickycheers "rickycheers (3 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/domainvalidity-php-domain-validator/health.svg)

```
[![Health](https://phpackages.com/badges/domainvalidity-php-domain-validator/health.svg)](https://phpackages.com/packages/domainvalidity-php-domain-validator)
```

###  Alternatives

[marcosh/php-validation-dsl

A DSL for validating data in a functional fashion

483.9k](/packages/marcosh-php-validation-dsl)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
