PHPackages                             souplette/fusbup - 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. souplette/fusbup

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

souplette/fusbup
================

A fast &amp; memory-efficient interface to the Mozilla Public Suffix List.

1.0.14(6mo ago)1672[1 PRs](https://github.com/souplette-php/fusbup/pulls)2MITPHPPHP &gt;=8.1CI passing

Since Feb 5Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/souplette-php/fusbup)[ Packagist](https://packagist.org/packages/souplette/fusbup)[ RSS](/packages/souplette-fusbup/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (44)Used By (2)

souplette/fusbup
================

[](#souplettefusbup)

[![codecov](https://camo.githubusercontent.com/7732480ad18dcd2d2ca6546ef6ccb02043f326f3136fc73b9bea1a78b5f60504/68747470733a2f2f636f6465636f762e696f2f67682f736f75706c657474652d7068702f6675736275702f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d62637255317275374946)](https://codecov.io/gh/souplette-php/fusbup)

A fast and memory-efficient PHP library to query the [Mozilla public suffix list](https://publicsuffix.org/).

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

[](#installation)

```
composer require souplette/fusbup
```

Basic usage
-----------

[](#basic-usage)

### Querying effective top-level domains (eTLD)

[](#querying-effective-top-level-domains-etld)

```
use Souplette\FusBup\PublicSuffixList;

$psl = new PublicSuffixList();
// get the eTLD (short for Effective Top-Level Domain) of a domain
assert($psl->getEffectiveTLD('foo.co.uk') === 'co.uk');
// check if a domain is an eTLD
assert($psl->isEffectiveTLD('fukushima.jp'));
// split a domain into it's private and eTLD parts
assert($psl->splitEffectiveTLD('www.foo.co.uk') === ['www.foo', 'co.uk']);
```

### Querying registrable domains (AKA eTLD+1)

[](#querying-registrable-domains-aka-etld1)

```
use Souplette\FusBup\PublicSuffixList;

$psl = new PublicSuffixList();
// get the registrable part (eTLD+1) of a domain
assert($psl->getRegistrableDomain('www.foo.co.uk') === 'foo.co.uk');
// split a domain into it's private and registrable parts.
assert($psl->splitRegistrableDomain('www.foo.co.uk') === ['www', 'foo.co.uk']);
```

### Checking the applicability of a cookie domain

[](#checking-the-applicability-of-a-cookie-domain)

The `PublicSuffixList` class implements the [RFC6265 algorithm](https://httpwg.org/specs/rfc6265.html#cookie-domain)for matching a cookie domain against a request domain.

```
use Souplette\FusBup\PublicSuffixList;

$psl = new PublicSuffixList();
// check if a cookie domain is applicable to a hostname
$requestDomain = 'my.domain.com'
$cookieDomain = '.domain.com';
assert($psl->isCookieDomainAcceptable($requestDomain, $cookieDomain));
// cookie are rejected if their domain is an eTLD:
assert(false === $psl->isCookieDomainAcceptable('foo.com', '.com'))
```

### Internationalized domain names

[](#internationalized-domain-names)

All `PublicSuffixList` methods that return domains return them in their [normalized ASCII](https://url.spec.whatwg.org/#idna) form.

```
use Souplette\FusBup\PublicSuffixList;
use Souplette\FusBup\Utils\Idn;

$psl = new PublicSuffixList();
assert($psl->getRegistrableDomain('☕.example') === 'xn--53h.example');
// use Idn::toUnicode() to convert them back to unicode if needed:
assert(Idn::toUnicode('xn--53h.example') === '☕.example');
```

Performance
-----------

[](#performance)

The public suffix list contains about 10 000 rules as of 2023. In order to be maximally efficient for all uses cases, the `PublicSuffixList` class can use two search algorithms with different performance characteristics.

The first one (and the default) uses a [DAFSA](https://en.wikipedia.org/wiki/Deterministic_acyclic_finite_state_automaton)compiled to a binary string (this is the algorithm used in the Gecko and Chromium engines). The second one uses a compressed suffix tree compiled to PHP code.

Here is a summary of their respective pros and cons:

- DAFSA
    - 👍 more memory efficient (this is just a 50Kb string in memory)
    - 👍 faster to load (around 20μs on a SSD)
    - 👎 slower to search (in the order of 100 000 ops/sec)
- Suffix tree
    - 👎 less memory efficient (about 4Mb in memory)
    - 👎 slower to load (around 4ms without opcache, 500μs when using opcache preloading)
    - 👍 faster to search (in the order of 1 000 000 ops/sec)

Note that in both cases, the database will be lazily loaded.

### Which search algorithm should I use?

[](#which-search-algorithm-should-i-use)

Well, it depends on your use case but based on the aforementioned characteristics I would say: stick to the default (DAFSA) algorithm unless your app is going to make more than a few hundreds searches per seconds.

### Tell me how can I use them?

[](#tell-me-how-can-i-use-them)

Both algorithm can be used by passing the appropriate loader to the `PublicSuffixList` constructor.

#### DAFSA

[](#dafsa)

```
use Souplette\FusBup\Loader\DafsaLoader;
use Souplette\FusBup\PublicSuffixList;

$psl = new PublicSuffixList(new DafsaLoader());
// since DafsaLoader is the default, the following is equivalent:
$psl = new PublicSuffixList();
```

#### Suffix Tree

[](#suffix-tree)

```
use Souplette\FusBup\Loader\SuffixTreeLoader;
use Souplette\FusBup\PublicSuffixList;

$psl = new PublicSuffixList(new SuffixTreeLoader());
```

You should also configure opcache to preload the database:

In your `php.ini`:

```
opcache.enabled=1
opcache.preload=/path/to/my/preload-script.php
```

In your preload script:

```
opcache_compile_file('/path/to/vendor/ju1ius/fusbup/Resources/psl.php');
```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance80

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 56.9% 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 ~24 days

Recently: every ~65 days

Total

42

Last Release

199d ago

Major Versions

0.4.22 → 1.0.02024-02-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/db8c537fa479fd389b9ef832345ebf665f767e3ff7c7c345bc0ba4c52b46a22f?d=identicon)[ju1ius](/maintainers/ju1ius)

---

Top Contributors

[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (78 commits)")[![ju1ius](https://avatars.githubusercontent.com/u/218404?v=4)](https://github.com/ju1ius "ju1ius (59 commits)")

---

Tags

cookiedomaineffective-tldetldicannpublic-suffix-listtldtop-level-domaincookiedomaintldPublic Suffix ListicannPSLtop level domaineffective tldetld

### Embed Badge

![Health badge](/badges/souplette-fusbup/health.svg)

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

###  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)[spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

1.5k4.7M20](/packages/spatie-laravel-cookie-consent)[statikbe/laravel-cookie-consent

Cookie consent modal for EU

213396.7k](/packages/statikbe-laravel-cookie-consent)[bakame/laravel-domain-parser

Laravel package to integrate PHP Domain parser.

26534.8k4](/packages/bakame-laravel-domain-parser)[dirkpersky/typo3-dp_cookieconsent

Enable a cookie consent box. Let you visitors control the usage of cookies and load script or content after a consent. (ePrivacy, TTDSG)

36201.3k1](/packages/dirkpersky-typo3-dp-cookieconsent)[aura/payload-interface

An interface package for Domain Payload implementations.

13392.7k4](/packages/aura-payload-interface)

PHPackages © 2026

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