league/uri-polyfill
Polyfill for league/uri that supplies compatible URI parsing and manipulation classes, letting applications keep using the League URI API on environments where the full package or required extensions are unavailable. A drop-in compatibility layer for URL handling.
What it actually is. league/uri-polyfill is not a URI manipulation library — it is a thin compatibility shim that defines the Uri\Rfc3986\Uri and Uri\WhatWg\Url classes in the global Uri\ namespace for PHP versions that predate the native URI parsing extension. It exists so that code written against the forthcoming native API can run today and continue running unchanged after the PHP upgrade. The [READ-ONLY] marker indicates it is a subtree split published from the thephpleague/uri monorepo; the low star count and zero dependents are artifacts of that split, not independent quality signals.
Architecture fit. Fit is narrow but clean. It is appropriate for two cases: (a) library or shared-package authors who want to ship one code path against the native API across a PHP version range, and (b) application teams who want a forward-compatible URI API with a delete-later story. It is inappropriate as a general URI toolkit — teams already using league/uri for parsing/validation/manipulation get nothing here and should not swap.
Integration feasibility. Mechanically trivial: one Composer requirement, PSR-4 autoloading plus a class_exists()-guarded bootstrap file. No configuration, no service provider, no framework coupling. The real effort is not installation but verification — proving the polyfill and the future native implementation behave identically on your inputs.
Technical risk.
Uri\ classes yields a fatal error, and opcache preloading changes when the guard executes.ext-intl or a pure-PHP IDNA fallback, changing your deployment baseline for a package you intend to delete.thephpleague/uri. Your SCA tooling may under-report.Key questions for the maintainers.
provide/replace to prevent coexistence with conflicting shims?ext-intl-backed or pure PHP, and what is the perf/memory delta?Stack fit. Composer/PHP, zero framework coupling, safe in any Laravel version. Place it in require only where production code calls the Uri\ classes; otherwise confine it to require-dev for tests. Note that Laravel's HTTP stack (Guzzle, Symfony HttpFoundation) does not consume this API today, so adoption is a local decision, not an ecosystem-forced one.
Migration path. This is the rare dependency with a designed exit — treat that as its primary value:
Uri\Rfc3986\Uri / Uri\WhatWg\Url.league/uri in require-dev as an oracle and assert parity across a corpus of real production URLs (including adversarial: IDN hosts, mixed-case schemes, .. segments, encoded delimiters).composer remove the polyfill, ship zero application code changes.Compatibility gates. Verify: PHP floor supported, ext-intl availability in every environment (local, CI, prod images), conflict declarations against other Uri\ shims, and interaction with opcache preloading. Framework version is effectively a non-issue.
Sequencing. (1) Confirm PHP floor and polyfill support matrix. (2) Land it behind a thin internal wrapper class rather than calling Uri\ directly, so you can swap implementations without a repo-wide refactor. (3) Build the parity harness before rollout — this is the gating deliverable. (4) Ship to one bounded use case with low blast radius (e.g., canonicalizing inbound URLs for cache keys, with the old path still authoritative). (5) Expand scope only after parity is demonstrated in production. (6) Open the removal ticket at adoption time, triggered by the PHP upgrade, so it does not become permanent scaffolding.
Maintenance. Low steady-state cost — the package is a set of class definitions with no runtime state. However, [READ-ONLY] means you cannot patch in place: every fix routes through the upstream monorepo. At organizational scale, pre-negotiate a fork-and-patch contingency rather than discovering the constraint during an incident.
Support. No independent issue tracker, no independent release notes, no independent roadmap. All of it lives in thephpleague/uri. The 1-star / 0-dependent profile should be read as "unproven independently, backed by a well-known maintainer" — acceptable for a shim, unacceptable as an unexamined critical-path dependency.
Scaling. Negligible. No I/O, no shared state, no connection pools; parse cost is comparable to league/uri. Scales horizontally without thought. The only scaling caveat is memory in high-volume batch URL parsing if the pure-PHP IDNA path is used.
Failure modes, ranked by blast radius.
Cannot redeclare class after a PHP upgrade or a competing shim entering the tree. Mitigation: dependency-graph assertion in CI, and verify the bootstrap guard under opcache preload.thephpleague/uri directly in addition to the split.ext-intl or IDNA dependency appearing under a package you consider disposable.Ramp-up. Effectively zero for anyone familiar with league/uri; the API surface is small. The actual learning investment is conceptual, not syntactic: engineers must internalize the RFC 3986 versus WHATWG distinction and the normalization/validation edge cases. Budget a half-day of review for the parity harness and a short design note on which spec governs each call site — that note, not the package, is what prevents the production incidents.
How can I help you explore Laravel packages today?