{"id":36982011,"url":"https://github.com/souplette-php/fusbup","last_synced_at":"2026-01-13T22:51:53.704Z","repository":{"id":65709456,"uuid":"594569057","full_name":"souplette-php/fusbup","owner":"souplette-php","description":"PHP library to query the Mozilla public suffix list","archived":false,"fork":false,"pushed_at":"2026-01-12T03:43:09.000Z","size":2703,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-12T10:35:17.416Z","etag":null,"topics":["cookie","domain","effective-tld","etld","icann","public-suffix-list","tld","top-level-domain"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/souplette-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-01-29T00:07:02.000Z","updated_at":"2026-01-12T03:43:13.000Z","dependencies_parsed_at":"2023-10-02T02:37:15.259Z","dependency_job_id":"d078e9e9-5221-4374-bd0a-d56a2f879cbd","html_url":"https://github.com/souplette-php/fusbup","commit_stats":{"total_commits":58,"total_committers":3,"mean_commits":"19.333333333333332","dds":"0.10344827586206895","last_synced_commit":"c425965f5ce952e3674f924a5fd8b4440f7c0c92"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"purl":"pkg:github/souplette-php/fusbup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souplette-php%2Ffusbup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souplette-php%2Ffusbup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souplette-php%2Ffusbup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souplette-php%2Ffusbup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/souplette-php","download_url":"https://codeload.github.com/souplette-php/fusbup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souplette-php%2Ffusbup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28402188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cookie","domain","effective-tld","etld","icann","public-suffix-list","tld","top-level-domain"],"created_at":"2026-01-13T22:51:53.499Z","updated_at":"2026-01-13T22:51:53.681Z","avatar_url":"https://github.com/souplette-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# souplette/fusbup\n\n[![codecov](https://codecov.io/gh/souplette-php/fusbup/branch/main/graph/badge.svg?token=bcrU1ru7IF)](https://codecov.io/gh/souplette-php/fusbup)\n\nA fast and memory-efficient PHP library to query the\n[Mozilla public suffix list](https://publicsuffix.org/).\n\n## Installation\n\n```sh\ncomposer require souplette/fusbup\n```\n\n## Basic usage\n\n### Querying effective top-level domains (eTLD)\n\n```php\nuse Souplette\\FusBup\\PublicSuffixList;\n\n$psl = new PublicSuffixList();\n// get the eTLD (short for Effective Top-Level Domain) of a domain\nassert($psl-\u003egetEffectiveTLD('foo.co.uk') === 'co.uk');\n// check if a domain is an eTLD\nassert($psl-\u003eisEffectiveTLD('fukushima.jp'));\n// split a domain into it's private and eTLD parts\nassert($psl-\u003esplitEffectiveTLD('www.foo.co.uk') === ['www.foo', 'co.uk']);\n```\n\n### Querying registrable domains (AKA eTLD+1)\n\n```php\nuse Souplette\\FusBup\\PublicSuffixList;\n\n$psl = new PublicSuffixList();\n// get the registrable part (eTLD+1) of a domain\nassert($psl-\u003egetRegistrableDomain('www.foo.co.uk') === 'foo.co.uk');\n// split a domain into it's private and registrable parts.\nassert($psl-\u003esplitRegistrableDomain('www.foo.co.uk') === ['www', 'foo.co.uk']);\n```\n\n### Checking the applicability of a cookie domain\n\nThe `PublicSuffixList` class implements the\n[RFC6265 algorithm](https://httpwg.org/specs/rfc6265.html#cookie-domain)\nfor matching a cookie domain against a request domain.\n\n```php\nuse Souplette\\FusBup\\PublicSuffixList;\n\n$psl = new PublicSuffixList();\n// check if a cookie domain is applicable to a hostname\n$requestDomain = 'my.domain.com'\n$cookieDomain = '.domain.com';\nassert($psl-\u003eisCookieDomainAcceptable($requestDomain, $cookieDomain));\n// cookie are rejected if their domain is an eTLD:\nassert(false === $psl-\u003eisCookieDomainAcceptable('foo.com', '.com'))\n```\n\n### Internationalized domain names\n\nAll `PublicSuffixList` methods that return domains\nreturn them in their [normalized ASCII](https://url.spec.whatwg.org/#idna) form.\n\n```php\nuse Souplette\\FusBup\\PublicSuffixList;\nuse Souplette\\FusBup\\Utils\\Idn;\n\n$psl = new PublicSuffixList();\nassert($psl-\u003egetRegistrableDomain('☕.example') === 'xn--53h.example');\n// use Idn::toUnicode() to convert them back to unicode if needed:\nassert(Idn::toUnicode('xn--53h.example') === '☕.example');\n```\n\n\n## Performance\n\nThe public suffix list contains about 10 000 rules as of 2023.\nIn order to be maximally efficient for all uses cases,\nthe `PublicSuffixList` class can use two search algorithms\nwith different performance characteristics.\n\nThe first one (and the default) uses a [DAFSA](https://en.wikipedia.org/wiki/Deterministic_acyclic_finite_state_automaton)\ncompiled to a binary string (this is the algorithm used in the Gecko and Chromium engines).\nThe second one uses a compressed suffix tree compiled to PHP code.\n\nHere is a summary of their respective pros and cons:\n\n* DAFSA\n  * 👍 more memory efficient (this is just a 50Kb string in memory)\n  * 👍 faster to load (around 20μs on a SSD)\n  * 👎 slower to search (in the order of 100 000 ops/sec)\n* Suffix tree\n  * 👎 less memory efficient (about 4Mb in memory)\n  * 👎 slower to load (around 4ms without opcache, 500μs when using opcache preloading)\n  * 👍 faster to search (in the order of 1 000 000 ops/sec)\n\nNote that in both cases, the database will be lazily loaded.\n\n### Which search algorithm should I use?\n\nWell, it depends on your use case but based on the aforementioned characteristics\nI would say: stick to the default (DAFSA) algorithm unless your app\nis going to make more than a few hundreds searches per seconds.\n\n### Tell me how can I use them?\n\nBoth algorithm can be used by passing the appropriate loader to the `PublicSuffixList` constructor.\n\n#### DAFSA\n\n```php\nuse Souplette\\FusBup\\Loader\\DafsaLoader;\nuse Souplette\\FusBup\\PublicSuffixList;\n\n$psl = new PublicSuffixList(new DafsaLoader());\n// since DafsaLoader is the default, the following is equivalent:\n$psl = new PublicSuffixList();\n```\n\n#### Suffix Tree\n\n```php\nuse Souplette\\FusBup\\Loader\\SuffixTreeLoader;\nuse Souplette\\FusBup\\PublicSuffixList;\n\n$psl = new PublicSuffixList(new SuffixTreeLoader());\n```\n\nYou should also configure opcache to preload the database:\n\nIn your `php.ini`:\n\n```ini\nopcache.enabled=1\nopcache.preload=/path/to/my/preload-script.php\n```\n\nIn your preload script:\n```php\nopcache_compile_file('/path/to/vendor/ju1ius/fusbup/Resources/psl.php');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsouplette-php%2Ffusbup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsouplette-php%2Ffusbup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsouplette-php%2Ffusbup/lists"}