Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Uri Laravel Package

league/uri

league/uri provides simple, intuitive PHP classes for parsing, building, and manipulating URIs, with support for IDN hosts, IPv4 conversion, PSR-7 interoperability, and RFC-compliant handling. Requires PHP 8.1+.

View on GitHub
Deep Wiki
Context7

[READ-ONLY] URI manipulation Library

Frequently asked questions about Uri
How do I install league/uri in a Laravel application?
Run composer require league/uri in the Laravel project. There is no service provider, config file, or container binding to register; use the classes directly where you parse or build URLs. The package requires PHP 8.1 or newer, which matches current Laravel 10, 11, and 12 baselines.
Does league/uri support Laravel 10, 11, and 12?
It is a framework-agnostic PHP library, so Laravel support depends mostly on the PHP version. league/uri requires PHP 8.1+, so it fits Laravel 10, 11, and 12 environments that meet that baseline. You still need to confirm required PHP extensions such as intl, gmp or bcmath, and dom on each deploy target.
How should I parse user-supplied URLs safely with league/uri in Laravel?
Use the non-throwing entry points such as Uri::parse, Uri::tryNew, or Http::tryNew for request data, because the constructors throw on invalid input. Check for a null return and reject or log invalid URLs before using them. This keeps malformed redirects, callbacks, and webhook targets from turning into uncaught exceptions.
What is the difference between League\Uri\Uri and League\Uri\Http?
Uri follows RFC 3986 semantics, while Http is the PSR-7 Http implementation with WHATWG-aligned behavior. They can differ on details such as leading-slash normalization of getPath, so mixing them in one code path can cause subtle bugs. Pick the one that matches the boundary you are working at and keep that choice consistent.
How do I handle international domain names with league/uri?
league/uri supports IDN hosts, but validation or interaction with IDN hosts requires ext-intl or a polyfill such as symfony/polyfill-intl-idn. Without it, an exception is thrown when the library tries to process the host. Add the extension or polyfill to every runtime image and CI job that parses customer-facing URLs.
Why does league/uri throw an exception about ext-intl, GMP, or DOM?
Those exceptions indicate optional platform capabilities are missing for the operation you requested. IDN host handling needs ext-intl or a polyfill, IPv4 conversion needs GMP, BCMath, or 64-bit PHP, and HTML-related parsing needs ext-dom. Check the deploy image, Lambda or Vapor layer, or CI image and install the required extension or polyfill before calling that code path.
Does league/uri replace Laravel's url(), route(), or router?
No. Laravel's URL helpers and router generate URLs from application state such as named routes and request context, while league/uri works from RFC grammar. Use league/uri at boundaries for parsing, validating, canonicalizing, or rewriting URLs, and keep route() and url() for generating application routes. Replacing them would lose framework-aware behavior.
Can league/uri help normalize webhook and callback URLs for allowlisting?
Yes. It is well suited to canonicalizing inbound redirect or callback URLs and outbound webhook targets before comparing them with an allowlist. Parse with the non-throwing methods, normalize the components you care about, then compare against trusted values. Be explicit about which class you use, because Uri and Http differ in some normalization behavior.
How does league/uri integrate with PSR-7 and PSR-17 in Laravel?
It exposes a PSR-7 Http implementation and a PSR-17 HttpFactory, so it works with stacks that already consume those interfaces. Laravel's HTTP client ecosystem speaks PSR-7/PSR-17, which makes the library easy to slot in at HTTP boundaries. It does not need a Laravel service provider or config to use those classes.
Which league/uri version should I pin in a Laravel project?
Pin a specific 7.x release rather than using a loose constraint, because minor 7.x upgrades have carried deprecations and API surface changes. If you use UriTemplate::expandToPsr7, use 7.9.0 or newer because older versions implemented it incorrectly. Also verify release and dependent metadata on Packagist before making maintenance-velocity claims.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource