rowbot/url
A PHP implementation of the WHATWG URL Standard for parsing and manipulating URLs with spec-compliant accuracy. It handles internationalized domains, percent-encoding, relative resolution, and edge cases browsers agree on, offering a dependable alternative to PHP's parse_url for modern URL work.
parse_url() and the browser's URL parser disagree on host, scheme, and path for the same string. A WHATWG-compliant parser lets us validate the same interpretation the browser and any downstream HTTP client will use, which directly supports go/no-go on features like user-configured webhooks and outbound fetches (SSRF allowlisting, open-redirect prevention).rel=canonical, sitemap generation), duplicate-content detection, dedupe of submitted links in a feed or directory product, and stable cache keys for URL-keyed resources. The package's query-string handling additionally supports UTM/tracking-param stripping and allowlist matching on a normalized param set rather than raw strings.UrlParser interface so swapping to league/uri or guzzlehttp/psr7 is a one-file change, and so the choice never leaks into domain code.Adopt when:
urljoin) without writing it yourself.& and =.UriInterface implementation that can slot into an existing Guzzle/HTTP-client stack.Look elsewhere when:
league/uri (mature, widely depended on, RFC 3986 + PSR-7) or the URI implementation already shipped with your HTTP client. Note the tradeoff: those are RFC 3986, not WHATWG, so they will not reproduce browser behavior on the messy inputs that motivate this package.parse_url() plus a known-host check is sufficient when inputs are trusted or constrained.urltestdata.json corpus, PHP version support, and whether the reported 2026-10-03 release is real and not a metadata artifact.To executives: We're adding URL-handling features (user-supplied links, webhooks, link previews, canonical URLs for SEO). Today we'd parse those with PHP's built-in function, which reads URLs differently than browsers do — the classic root cause of open-redirect and SSRF bypasses. This is a small, free (MIT) library that parses URLs exactly the way browsers do, so our validation and our HTTP client agree on what a link points to. Cost is a few days of integration; the payoff is closing a known class of security bug before we ship the feature, plus one shared primitive for every link feature on the roadmap. The main caveat is that it's a low-adoption, single-maintainer project, so we'll wrap it behind our own interface and keep the swap to a more established library to a one-file change.
To engineering: WHATWG-spec-compliant parser, pure PHP, no Laravel coupling, PSR-7 UriInterface, includes query-string parse/build and relative resolution. It closes the parse_url() vs. browser divergence (backslashes, whitespace, default ports, dot segments, IDN) that we'd otherwise have to patch around. Low adoption is the risk, not the code: it has ~19 stars and no dependents. So: consume it through a single internal adapter, pin the version, add contract tests around the WHATWG urltestdata fixtures, and don't let its types into domain models. If it goes stale, we replace the adapter with league/uri — at the cost of losing browser-identical behavior, which we should re-evaluate at that point.
How can I help you explore Laravel packages today?