PHPackages                             xoops/regdom - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. xoops/regdom

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xoops/regdom
============

A robust domain parser for PHP, using the Mozilla Public Suffix List to determine the registrable domain and validate cookie domains per RFC 6265.

v2.0.1(1y ago)06.8k↓50%12Apache-2.0PHPPHP &gt;=7.4.0CI failing

Since Jul 8Pushed 2mo agoCompare

[ Source](https://github.com/XOOPS/RegDom)[ Packagist](https://packagist.org/packages/xoops/regdom)[ Docs](https://github.com/XOOPS/RegDom)[ RSS](/packages/xoops-regdom/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (8)Used By (2)

[![alt XOOPS CMS](https://camo.githubusercontent.com/afcc8bbe53ee000d859b25f55229b090203cf7ef7e8f8a6ff1c0222dce8bce9e/68747470733a2f2f786f6f70732e6f72672f696d616765732f6c6f676f586f6f7073344769746875625265706f7369746f72792e706e67)](https://camo.githubusercontent.com/afcc8bbe53ee000d859b25f55229b090203cf7ef7e8f8a6ff1c0222dce8bce9e/68747470733a2f2f786f6f70732e6f72672f696d616765732f6c6f676f586f6f7073344769746875625265706f7369746f72792e706e67)

RegDom - Registered Domain Check in PHP
=======================================

[](#regdom---registered-domain-check-in-php)

Object oriented PHP library for querying Mozilla's Public Suffix List to determine the registrable domain portion of URLs and validate cookie domains per RFC 6265. Adapted from Florian Sager's regdom library.

For more information on public suffixes, see [publicsuffix.org](https://publicsuffix.org/).

Requirements
------------

[](#requirements)

- PHP 8.2 or later
- `ext-mbstring` required
- `ext-intl` recommended (for internationalized domain name support)

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

[](#installation)

```
composer require xoops/regdom
```

Usage
-----

[](#usage)

### Extracting the Registered Domain

[](#extracting-the-registered-domain)

```
use Xoops\RegDom\RegisteredDomain;

$regdom = new RegisteredDomain();

echo $regdom->getRegisteredDomain('https://www.google.com/');
// Output: google.com

echo $regdom->getRegisteredDomain('theregister.co.uk');
// Output: theregister.co.uk

var_dump($regdom->getRegisteredDomain('co.uk'));
// Output: NULL (co.uk is a public suffix, not a registrable domain)

// IDN support (requires ext-intl)
echo $regdom->getRegisteredDomain('www.münchen.de');
// Output: münchen.de
```

### Cookie Domain Validation (RFC 6265)

[](#cookie-domain-validation-rfc-6265)

```
use Xoops\RegDom\RegisteredDomain;

// Validates if a cookie domain is appropriate for a given host
RegisteredDomain::domainMatches('www.example.com', 'example.com');  // true
RegisteredDomain::domainMatches('example.com', 'com');              // false (public suffix)
RegisteredDomain::domainMatches('google.com', 'facebook.com');      // false (cross-domain)
RegisteredDomain::domainMatches('192.168.1.1', '192.168.1.1');      // false (IP addresses)
```

### Querying the Public Suffix List

[](#querying-the-public-suffix-list)

```
use Xoops\RegDom\PublicSuffixList;

$psl = new PublicSuffixList();

$psl->isPublicSuffix('com');        // true
$psl->isPublicSuffix('co.uk');      // true
$psl->isPublicSuffix('example.com'); // false

$psl->getPublicSuffix('www.example.co.uk'); // 'co.uk'

$psl->isException('www.ck'); // true (PSL exception rule)
```

### Checking PSL Cache Status

[](#checking-psl-cache-status)

```
$metadata = $psl->getMetadata();
// Returns: active_cache, last_updated, days_old, rule_counts, needs_update
```

### Updating the Public Suffix List

[](#updating-the-public-suffix-list)

```
composer run update-psl
```

Set the `XOOPS_SKIP_PSL_UPDATE` environment variable to skip automatic PSL updates during `composer install`/`update` (useful in CI or restricted networks).

Configuration
-------------

[](#configuration)

### XOOPS\_COOKIE\_DOMAIN\_USE\_PSL

[](#xoops_cookie_domain_use_psl)

When defined and set to `false`, disables PSL-based validation in `RegisteredDomain::domainMatches()`. Defaults to `true` when undefined.

### XOOPS\_SKIP\_PSL\_UPDATE

[](#xoops_skip_psl_update)

Environment variable. When set (to any value), prevents automatic PSL download during Composer post-install/update hooks.

Development
-----------

[](#development)

```
composer install          # Install dependencies
composer ci               # Run all checks: lint + analyse + test
composer test             # Run PHPUnit tests
composer lint             # Check code style (PSR-12)
composer analyse          # Run PHPStan (level max)
composer fix              # Auto-fix code style issues
```

Credits
-------

[](#credits)

Reg-dom was written by Florian Sager, 2009-02-05,

Marcus Bointon's adapted code:

License
-------

[](#license)

The PHP library code in this repository is licensed under the Apache License 2.0. See [LICENSE.txt](LICENSE.txt) for the full Apache 2.0 license text.

The bundled Public Suffix List data/cache is derived from Mozilla's Public Suffix List and is available under the Mozilla Public License 2.0 (MPL-2.0). For details, see  and .

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance64

Regular maintenance activity

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.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 ~99 days

Recently: every ~113 days

Total

7

Last Release

85d ago

PHP version history (3 changes)v2.0.0-AlphaPHP &gt;=7.4.0

v2.0.2-beta2PHP ^7.4 || ^8.0

v2.1.0-beta1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7eb0c56896d2405e44608ffb77c1411e4a18927be440b28275f7e0cb075ea9d6?d=identicon)[geekwright](/maintainers/geekwright)

---

Top Contributors

[![mambax7](https://avatars.githubusercontent.com/u/613686?v=4)](https://github.com/mambax7 "mambax7 (87 commits)")[![geekwright](https://avatars.githubusercontent.com/u/3181636?v=4)](https://github.com/geekwright "geekwright (40 commits)")[![Synchro](https://avatars.githubusercontent.com/u/81561?v=4)](https://github.com/Synchro "Synchro (4 commits)")

---

Tags

publictldsuffixregdom

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xoops-regdom/health.svg)

```
[![Health](https://phpackages.com/badges/xoops-regdom/health.svg)](https://phpackages.com/packages/xoops-regdom)
```

###  Alternatives

[jeremykendall/php-domain-parser

Public Suffix List and IANA Root Zone Database based Domain parsing implemented in PHP.

1.2k13.0M77](/packages/jeremykendall-php-domain-parser)[markbaker/tries

PHP Classes for Trie datastructures

211.6k](/packages/markbaker-tries)

PHPackages © 2026

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