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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. xoops/regdom

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

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.1.1(5mo ago)06.8k↓92.9%12(Apache-2.0 OR MPL-2.0)PHPPHP ^8.2CI failing

Since Jul 8Pushed 3w agoCompare

[ Source](https://github.com/XOOPS/RegDom)[ Packagist](https://packagist.org/packages/xoops/regdom)[ Docs](https://github.com/XOOPS/RegDom)[ Fund](https://xoops.org/modules/donations/)[ GitHub Sponsors](https://github.com/sponsors/XOOPS)[ RSS](/packages/xoops-regdom/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (6)Versions (10)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

48

—

FairBetter than 94% of packages

Maintenance84

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity59

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 ~74 days

Recently: every ~36 days

Total

9

Last Release

176d 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

parsercookiedomainpublictldPSLsuffixregdomRFC6265

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### 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

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.2B15.1k](/packages/symfony-console)[symfony/symfony

The Symfony PHP framework

31.4k87.4M2.2k](/packages/symfony-symfony)[symfony/http-foundation

Defines an object-oriented layer for the HTTP specification

8.7k950.4M7.2k](/packages/symfony-http-foundation)[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

43.6k344.8k1](/packages/ccxt-ccxt)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k257.3M12.4k](/packages/symfony-framework-bundle)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k39.6k](/packages/matomo-matomo)

PHPackages © 2026

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