league/uri-components
Immutable value objects for concrete URI components (host, path, query, etc.) in the League URI ecosystem. Requires PHP 8.1+. Supports IDN hosts with intl (or polyfill) and IPv4 conversion via GMP/BCMath or 64-bit PHP.
Query::withList, Query::filter).Modifier::normalizeHost, Modifier::normalizeIp) for canonicalization and deduplication.Modifier::redactUserInfo, Modifier::redactPathSegments) to prevent exposure of sensitive data in logs or URLs.Domain::isSubdomainOf).intl extension or polyfills, critical for global applications.Modifier::replaceQueryPair, Modifier::prependPath).Query::indexOfValue, Path::contains) for clickstream or A/B testing data pipelines.Adopt When:
parse_str/http_build_query.Look Elsewhere If:
league/uri or symfony/psr-http-message instead).URL API or url-pattern).ext/standard functions).For Executives: "This package lets us treat URLs as structured data—like JSON for web addresses—so we can safely manipulate, validate, and transform them without bugs. For example, we can automatically clean up messy query strings from third-party APIs, standardize domain formats for global users, or redact sensitive info from logs. It’s a drop-in solution that saves dev time and reduces security risks, with zero licensing costs (MIT license). Think of it as ‘Laravel’s built-in URI sanitizer and query-string Swiss Army knife.’"
For Engineers:
*"league/uri-components gives you immutable, PSR-7-compatible URI parts (scheme, host, path, query, etc.) with modern PHP features like BackedEnum support and fluent modifiers. Key wins:
Query::filter()->map() for complex transformations.Domain::isSubdomainOf), find segments (Path::indexOf), or normalize IPs.Modifier::redactPathSegments) or validate IDNs without reinventing the wheel.Illuminate\Support\Facades\URL or standalone.
Example use case: Replace a spaghetti str_replace mess for URL cleaning with Modifier::normalizeHost()->withoutEmptyQueryPairs(). Docs are solid, and it’s actively maintained (last release: 2026)."*How can I help you explore Laravel packages today?