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.
Illuminate\Http\Request, Illuminate\Support\Str), URL generation (url(), route()), and API resources (e.g., Resource::toResponse()).UrlGenerator) while providing focused utilities (resolve, normalize, parse, build, split). Ideal for microservices, API gateways, or legacy monoliths needing URI standardization.file:///C:/path vs. /mnt/c/path).HandleIncomingRedirect).store() methods).toArray()).$this->app->bind(UriResolver::class, function ($app) {
return new \Sabre\Uri\UriResolver();
});
Illuminate\Auth\Events\Login or Illuminate\Queue\Events\JobProcessed.schedule:run) or migrations (e.g., checking file:// paths for storage links).3.1.0 drops PHP 7.4–8.1). Mitigate by:
^3.0 in composer.json for backward compatibility.2.2.4 but may resurface).https://例.测试).///example.com).s3://)? If yes, this package is a must.3.1.0) or 7.4–8.1 (for 3.0.*)? Check composer.json constraints.parse_url() hacks)? Rector (#139) can automate migration.file:// URIs? Test edge cases like file:///C:/path vs. /mnt/c/path.parse_url() in Illuminate\Http\Request extensions or middleware.RouteServiceProvider or api.php routes.toArray() or toResponse() methods.HandleJob classes (e.g., Storage::disk('s3')->url($path)).Illuminate\Auth\Events\Login or Illuminate\Queue\Events\JobProcessed.stripe_url in Stripe_Webhook handlers.SlackClient::sendMessage().s3:// paths in custom storage adapters.sabre/uri in DataProvider tests for URI edge cases.it('resolves relative paths', ...)).parse_url, explode('/'), regex).parse_url() calls:
// Before
parse_url($uri);
// After (via Rector)
\Sabre\Uri\parse($uri);
composer.json:
"require": {
"sabre/uri": "^3.0"
}
3.1.0).3.0.* (PHP 7.4–8.1).2.3.* (PHP 7.4+).file:// URIs.parse_url() in HTTP layer (middleware, controllers).HandleIncomingRedirect).dependabot.yml (included in the repo).3.0.* supports PHP 7.4–8.5; 3.1.0 is PHP 8.2+.4.0.0).How can I help you explore Laravel packages today?