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 Interfaces

Uri Interfaces Laravel Package

league/uri-interfaces

Lightweight PHP package providing interfaces for representing URI objects according to RFC 3986. Includes IDN host and IPv4 handling via the intl extension or polyfills, requires PHP 8.1 or newer, and serves as the shared contract underlying the League URI components.

View on GitHub
Deep Wiki
Context7

League URI Interfaces provides the RFC 3986 compliant interfaces used to represent URI objects in PHP. It defines the contracts behind the League URI ecosystem, making it easy to type-hint and build interoperable URI handling in your own code.

  • RFC 3986 compliant URI interface
  • Requires PHP >= 8.1
  • IDN host support via intl or a polyfill
  • IPv4 conversion with GMP, BCMath, or 64-bit PHP
  • Sub-split of thephpleague/uri-src for development

Install with composer require league/uri-interfaces.

Frequently asked questions about Uri Interfaces
What is league/uri-interfaces used for in Laravel?
It provides PHP 8.1+ interfaces for representing and manipulating RFC 3986 URI objects. In Laravel, it lets you type-hint URI contracts such as UriInterface instead of coupling services to a concrete URI implementation. Use it for dependency injection, testing, mocking, or plugin architectures that need URI validation and manipulation. It does not replace Laravel’s built-in URL and Request URI handling.
How do I install league/uri-interfaces in a Laravel app?
Run composer require league/uri-interfaces. There is no Laravel service provider or config file because the package only defines interfaces. You can immediately type-hint the interfaces in your services. Choose a concrete implementation such as league/uri-components if you need actual URI parsing and manipulation.
Does league/uri-interfaces support Laravel 9, 10, and 11?
It requires PHP 8.1 or later, so it is compatible with Laravel 9+ environments. Laravel 8.x would need a PHP upgrade first. The package itself has no Laravel-specific version constraints beyond PHP. Check your app’s PHP version and Composer platform requirements before installing.
Do I need a service provider to use league/uri-interfaces?
No. The package is an interface-only contract layer and does not ship a Laravel service provider. You bind or inject a concrete URI implementation in your own service provider if needed. For simple type-hinting and testing, no container configuration is required.
What is the difference between HostRecord::parse and HostRecord::from in 7.9.0?
HostRecord::from throws when host parsing or validation fails, while HostRecord::parse returns a HostRecord or null. The parse method was added in 7.9.0 to provide a non-throwing path for host validation and normalization. Use parse when you want to handle invalid hosts without exceptions. Use from when an invalid host should fail fast.
Is league/uri-interfaces a replacement for Laravel’s URL and Request URI classes?
No. Laravel’s URL facade and Request URI methods use their own internal URI handling. This package defines contracts for URI objects and is intended for decoupling, testing, and injection. You may need adapters to bridge Laravel’s classes to these interfaces. It is best used as a contract layer rather than a direct replacement.
What extensions are required for IDN and IPv4 support in league/uri-interfaces?
IDN host handling requires the intl extension or a polyfill such as symfony/polyfill-intl-idn; otherwise an exception is thrown for such hosts. IPv4 conversion requires GMP, BCMath, or a 64-bit PHP build. Add the polyfill to composer.json if your production environment lacks intl. These requirements only matter when validating or converting internationalized hosts and IPv4 addresses.
Does upgrading to league/uri-interfaces 7.9.0 introduce breaking changes?
No breaking changes, deprecations, or removals were introduced in 7.9.0. Upgrading from 7.8.1 is a drop-in dependency bump via composer update league/uri-interfaces. The release includes behavioral bug fixes for Encoder encoding, removeDotSegments root preservation, and UriString normalization. Run regression tests if your code relies on previous edge-case output.
How should I test Laravel services that depend on league/uri-interfaces?
Because the package provides interfaces, you can mock UriInterface or other component interfaces with Laravel’s mocking tools such as Mockery. This makes it easier to test services without parsing real URIs. For integration tests, use a concrete implementation like league/uri-components. The new HostRecord::parse method also simplifies non-throwing host validation tests.
When should I use league/uri-interfaces instead of league/uri-components?
Use league/uri-interfaces when you only need contracts for type-hinting, dependency injection, mocking, or plugin boundaries. Use league/uri-components when you need concrete URI parsing, resolution, and manipulation. The interfaces package adds no runtime parsing logic. Many projects depend on both: the contract for application code and the implementation for actual URI work.
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.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
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