layershifter/tld-extract
Lightweight PHP library that extracts the top-level domain, domain name, and subdomain from URLs and email addresses using an accurate public suffix list. Simple static API returns structured results, making it easy to validate and parse domains in any Laravel or plain PHP project.
Architecture fit. layershifter/tld-extract is a framework-agnostic PHP library, not a Laravel package. It ships no service provider, no facade, no config file, and no publishable assets. That cuts both ways: there is nothing to conflict with Laravel's container or bootstrap lifecycle, but there is also no integration surface to lean on — we would own the wiring. Architecturally it is a pure function wrapped in a class: take a hostname, return subdomain / registrable domain / public suffix. That is a small, well-understood contract and easy to isolate behind an interface. Fit is high if the requirement is truly PSL-accurate domain decomposition (tenant subdomain routing, cookie scoping, registrable-domain grouping for rate limits or analytics, disposable/phishing heuristics). Fit is poor if the requirement is naive "last two labels," where the dependency adds risk for no benefit.
Integration feasibility. Apache-2.0 is permissive and compatible with a proprietary Laravel codebase, including modification and internal redistribution. Composer installation from Packagist still works for an archived package. The blocking concern is that the project is explicitly marked DEPRECATED and the repository is archived: last release 2019-02-11, which predates PHP 8 entirely. Feasibility therefore hinges on whether the code and its transitive dependencies (the author's companion TLD support/database packages) run unmodified on our PHP version — plausible for the parsing logic, uncertain for the dependency tree, and unverified without a spike.
Technical risk. The dominant risk is data staleness, and it is not a normal "bump the version" risk. A Public Suffix List parser is only as correct as its embedded PSL snapshot. The PSL changes continuously — new gTLDs, ccTLD rule changes, and the private-domains section used by hosted platforms. A 2019 snapshot is materially out of date, and because the library is archived there is no upstream path to refresh it short of us re-vendoring the data ourselves. Secondary risks: no security advisory coverage or CVE response, no PHP-version treadmill, zero reported dependents (i.e., almost no real-world validation or community pressure to fix defects), and silent wrong answers — a misparse returns a plausible-looking string rather than throwing. Silent incorrectness in domain parsing is a security-adjacent failure, not a cosmetic one.
Key questions.
jeremykendall/php-domain-parser) already vetted in our dependency policy?Stack fit. The library slots in as a plain Composer dependency consumed by a thin adapter: a DomainParser interface in the application layer, one adapter implementing it over TLDExtract, and binding in a service provider. Parsing is deterministic and cheap, so wrap the adapter in a request-scoped or cache-backed memoization layer to avoid repeated work in loops (URL sanitization, bulk import validation). No config publishing, migrations, or queue integration — the integration is a handful of lines plus tests.
Migration path. Do not adopt directly into application code. First run a short spike against the real requirement, and in parallel evaluate a maintained PSL parser. Because the contract is tiny, the cost of an interface-first approach is negligible and it makes the eventual replacement — or a move off this package entirely — a one-class change. If we do proceed, vendor it: fork into an internal namespace under our own versioning so we control the PSL data and PHP compatibility independently of an archived upstream.
Compatibility. Three axes to verify in the spike: PHP runtime compatibility at our version; the transitive dependency tree resolving cleanly without --ignore-platform-reqs; and behavioral compatibility of the returned structure (suffix/domain/subdomain) against our expected shape. Also confirm handling of IDN/punycode hosts and trailing-dot FQDNs, both of which commonly differ between PSL libraries.
Sequencing.
DomainParser interface and a golden-dataset test suite (100–200 known hosts, including edge cases) that is implementation-agnostic.Maintenance. This is the decisive factor. An archived library means we become the maintainers the moment it enters the dependency tree. Budget for a named owner, an internal fork, and a standing process to refresh the PSL snapshot on a defined cadence (monthly is typical). Without that owner, the package will decay silently while continuing to return confident, wrong answers.
Support. No upstream issue triage, no patches, no advisory feed. Apache-2.0 permits forking, so the exit ramp is legally clean, but there is no one to escalate to. The practical support model is internal ownership plus a documented runbook covering "PSL data is stale, here is how to refresh and re-test."
Scaling. Effectively free. PSL lookup is in-memory and O(labels), negligible against any Laravel request budget. The only scaling concern is accidental repeated parsing in bulk operations — solved with memoization, not architecture.
Failure modes. The library fails quietly, which is the worst profile. Realistic consequences: tenant subdomain misrouting if a suffix is treated as registrable; cookie scoping leaks if the registrable domain is over-broadened across sibling tenants; incorrect rate-limit or analytics grouping; email-domain validation rejecting valid modern domains. None of these raise an exception — they surface as support tickets or, worse, as a security review finding. A secondary failure mode is total: a PHP upgrade breaks the package and, with no upstream, blocks the platform upgrade until we fork.
Ramp-up. Low technically — a mid-level Laravel developer is productive in an afternoon with the interface and adapter pattern. The real ramp-up cost is institutional: establishing and staffing the PSL refresh process, defining accuracy acceptance tests, and getting the fork into the dependency policy. That overhead is disproportionate for a 210-star, zero-dependent, deprecated dependency, and it is the main reason the opportunity score of ~17.6 understates the total cost of ownership rather than overstating it.
How can I help you explore Laravel packages today?