Weave Code
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

sabre/uri

Lightweight PHP URI utility library compliant with RFC3986. Provides resolve, normalize, parse/build, and split helpers for working with URLs, including Windows-style path edge cases. Fully unit tested and inspired by Node.js URL handling.

View on GitHub
Deep Wiki
Context7

Functions for making sense out of URIs.

Frequently asked questions about Uri
How do I install **sabre/uri** in a Laravel project?
Add it via Composer: `composer require sabre/uri`. For Laravel 10+, use version `^3.1` for PHP 8.2+ support. Bootstrap it in `AppServiceProvider` as a singleton or wrap core functions in a facade for global access.
Does **sabre/uri** work with Laravel’s `url()` helper?
Yes, replace manual `url()` logic with `Uri::resolve($base, $relative)` for RFC3986-compliant resolution. Use it in routes, middleware, or services to standardize relative URL handling across your app.
Can I use **sabre/uri** to normalize URLs for caching?
Absolutely. The `normalize()` method standardizes URLs (e.g., converting `http://example.com/` to `http://example.com`) for consistent cache keys in Redis or database storage.
Will **sabre/uri** break if my app uses Windows file paths (e.g., `file:///C:/`)?
No—it’s explicitly tested for Windows paths. Unlike PHP’s `parse_url()`, it handles edge cases like `file:///C:/path` correctly, making it ideal for hybrid Windows/Linux deployments.
How does **sabre/uri** compare to Laravel’s built-in `parse_url()`?
It’s a drop-in replacement with RFC3986 compliance, Unicode support, and fixes for Windows paths. Use `Uri::parse()` instead of `parse_url()` for reliable parsing, especially in multilingual or cross-platform apps.
Is **sabre/uri** safe for production use in Laravel?
Yes, it’s 100% unit-tested with RFC3986 test cases and has zero dependencies. Benchmarks show <5% overhead vs. native `parse_url()`, and it’s used in production by Laravel apps needing strict URI validation.
Can I integrate **sabre/uri** with Laravel’s middleware?
Absolutely. Use `Uri::parse($request->getUri())` in middleware to validate incoming URLs (e.g., block open redirects) or normalize them for downstream processing.
Does **sabre/uri** support Laravel 9.x or older?
For Laravel 9.x (PHP 8.1), use `sabre/uri:^3.0`. Older versions (e.g., Laravel 8.x) require `^2.3` or lower. Check the [release table](https://github.com/sabre-io/uri) for PHP version compatibility.
How do I migrate from custom URI logic to **sabre/uri**?
Use Rector to automate replacements (e.g., `parse_url()` → `Uri::parse()`). Start with critical paths (e.g., routing, storage) and test edge cases like Unicode or Windows paths before full rollout.
Are there alternatives to **sabre/uri** for Laravel?
Laravel’s native `parse_url()` is limited (no RFC compliance or Windows path fixes). Other options like `ramsey/uuid` (for UUIDs) or `spatie/url` (for URL generation) don’t cover RFC3986 parsing. **sabre/uri** is the most standards-compliant choice for URI manipulation.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai