bakame/laravel-domain-parser
Laravel wrapper around the PHP Domain Parser library. Easily resolve registrable domains, public suffixes, and subdomains using the Public Suffix List, with a service provider, facade, and validation rule for reliable domain handling in Laravel apps.
Architecture fit: The package is a thin Laravel integration around a PHP Public Suffix List (PSL) parser, exposing service-container bindings, configuration, and likely a facade/artisan command for PSL updates. It fits Laravel applications that need correct registrable-domain extraction for multi-tenant subdomain routing, cookie scoping, email/domain validation, analytics grouping, SSO domain restrictions, or abuse controls. It is not a general validation or security boundary; it answers “what is the registrable domain?” and must be treated accordingly.
Integration feasibility: Composer-based installation is straightforward for a Laravel team. The main work is configuration, cache-store selection, PSL refresh scheduling, and wrapping the package behind an internal domain-parsing interface so application code does not depend directly on a low-adoption package. Feasibility is high for a bounded use case, but the package should be proven against the application’s actual domain patterns before broad adoption.
Technical risk: Primary risks are low adoption (26 stars, zero dependents), unclear long-term maintenance, Laravel/PHP version compatibility, and PSL data freshness. Incorrect or stale PSL data can misclassify domains and affect tenant isolation, cookie domains, or access rules. Additional risk exists around IDN/Unicode handling, cache behavior, and whether PSL updates happen at deploy time, schedule time, or runtime. Runtime network fetching would be an operational anti-pattern.
Key questions: Which Laravel and PHP versions are supported? Which underlying parser version is required, and is it actively maintained? How is the PSL sourced, cached, and refreshed? Does it support IDN/Unicode domains and private-section PSL rules? What happens when the PSL is stale or unavailable? Is there an artisan command suitable for scheduled updates? What is the test coverage and upgrade history? Can we isolate it behind an adapter and feature flag?
Stack fit: Suitable for Laravel monoliths or modular Laravel services that already use service-container configuration and scheduled tasks. Less suitable for non-Laravel PHP services or polyglot environments where a shared domain-parsing service would be preferable.
Migration path: Start with a time-boxed spike in a non-critical path, such as analytics grouping or display-only subdomain parsing. Compare outputs against the raw underlying parser and a curated fixture set covering ccTLDs, multi-level suffixes, IDNs, private suffixes, and malformed inputs. If results are sound, introduce an internal DomainParser interface, bind the package implementation behind it, and migrate call sites incrementally.
Compatibility: Verify Laravel version constraints, PHP version constraints, cache driver behavior, and whether config publishing is required. Pin the package and underlying parser versions in composer.json. Confirm that PSL updates are reproducible across environments and do not depend on outbound network access during request handling.
Sequencing: (1) Vendor risk and compatibility review; (2) fixture-based proof of concept; (3) internal adapter and tests; (4) scheduled PSL refresh in staging; (5) feature-flagged rollout to low-risk call sites; (6) expand to tenant routing or security-adjacent use only after operational evidence. Keep a fallback path to the underlying parser or a maintained alternative.
Maintenance: Low code footprint but elevated bus-factor risk due to low adoption. Pin versions, monitor upstream releases and PSL changes, and document ownership. Prefer scheduled PSL refresh over runtime fetching, and alert on refresh failures.
Support: Laravel developers can ramp up quickly, but PSL semantics—public suffix vs. registrable domain, private suffixes, IDNs—require explicit documentation and test fixtures. Support load should be low if the package is wrapped and not exposed directly to product teams.
Scaling: Parsing itself is cheap; the dominant scaling concern is caching PSL rules efficiently. Use a shared cache such as Redis or a preloaded in-memory structure per worker, and avoid per-request downloads. For high-throughput services, benchmark cache lookups and memory footprint.
Failure modes: Stale PSL data causing incorrect tenant or cookie domain resolution; cache eviction or corruption; failed scheduled updates; IDN edge cases; package incompatibility after Laravel/PHP upgrades; and silent misclassification if exceptions are swallowed. Instrument parse failures and anomalous domain classifications.
Ramp-up: Low for basic Laravel integration; moderate for correct PSL lifecycle and security-adjacent usage. Budget for a short proof of concept, fixture tests, and an internal adapter to contain vendor risk.
How can I help you explore Laravel packages today?