phrity/net-uri
Lightweight PSR-7 UriInterface and PSR-17 UriFactory implementation not tied to HTTP messaging. Supports any valid scheme plus helpful extras like query item helpers, component access, equals/string/json support, and immutable with* methods.
s3:// for AWS S3 paths, mailto: for email links, or custom app:// for internal routing), critical for hybrid cloud or multi-protocol integrations.withQueryItems() and getQueryItem(), reducing boilerplate in controllers or request handlers.北京.com) via IDN_ENCODE/IDN_DECODE modifiers, aligning with Laravel’s global application requirements (e.g., multilingual APIs or regional services).with* methods.php artisan s3:sync s3://bucket/path).Uri::create('/test')->withQueryItem('id', 1)).Adopt if:
withScheme(), withQueryItems()) over mutable objects.Equable, Stringable).Look elsewhere if:
Url or Guzzle’s Uri, which may offer tighter integration with Laravel’s routing/validation.spatie/url or ramsey/uuid for UUID URIs.Illuminate\Support\Facades\URL). This package is niche (0 dependents) but actively maintained.parse_url() or Symfony’s Url for baseline comparisons.*"This package standardizes how our Laravel applications handle URIs—critical for APIs, microservices, and global tools. By adopting it, we:
*"phrity/net-uri solves three key pain points in Laravel:
Url or Guzzle’s Uri in HTTP logic (e.g., middleware, clients). Example:
$uri = (new Phrity\Net\UriFactory())->createUri('/api/v1/users?page=2');
// Use in Laravel middleware or HTTP clients.
s3://, mailto:, or custom schemes without HTTP bloat. Ideal for CLI tools or multi-protocol integrations.$uri->withQueryItem('sort', 'name')->withQueryItem('direction', 'desc');
No more regex or parse_str() hacks!
Trade-offs:parse_url() but gains safety, immutability, and maintainability.Validator can cover gaps.
Recommendation: Pilot in a new microservice or CLI tool. If successful, replace Symfony’s Url in shared HTTP logic."**"This package enables URI abstraction in Laravel, decoupling URI handling from HTTP-specific logic. Key benefits:
app://, s3://) without monolithic libraries.Symfony\Component\HttpFoundation\Url in custom HTTP logic (e.g., middleware, clients).Phrity\Net\UriFactory as a PSR-17 factory in Laravel’s container for HTTP clients.Url for performance-critical paths.
Long-Term: Monitor Laravel’s core URI handling (Symfony) for alignment; this package remains a viable alternative for niche needs."*How can I help you explore Laravel packages today?