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, RFC3986-compliant PHP URI utility library. Resolve relative URLs, normalize for comparisons, parse/build (like parse_url with Windows path edge cases), and split URIs into dirname/basename. Fully unit tested and inspired by Node’s URL APIs.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Highly aligned with Laravel’s ecosystem, particularly for applications requiring RFC3986-compliant URI manipulation (e.g., API gateways, CMS platforms, or multi-cloud storage integrations).
  • Lightweight and dependency-free, making it ideal for performance-sensitive components (e.g., URL shorteners, CDN routing).
  • Complements Laravel’s built-in URL helpers (e.g., url(), route()) by providing low-level URI parsing/resolution for edge cases (e.g., Windows paths, Unicode, or relative references).
  • Stateless and pure-PHP, ensuring no external dependencies or runtime overhead, which is critical for serverless or high-throughput environments.

Integration Feasibility

  • Seamless with Laravel’s HTTP stack:
    • Can replace or augment Laravel’s Illuminate\Support\Str::of() or parse_url() for complex URI scenarios (e.g., resolving relative paths against a base URL).
    • Integrates with Laravel’s routing system (e.g., validating or normalizing incoming request URIs before dispatch).
    • Works alongside Laravel’s filesystem drivers (e.g., resolving file:// or s3:// URIs in storage logic).
  • Compatibility with modern PHP/Laravel:
    • Supports PHP 8.5 (via 3.0.3) and Laravel 11+, with backward compatibility for PHP 7.4+ (via 3.0.x).
    • No breaking changes in the 3.0.x series, making it a safe drop-in replacement for custom URI logic.
    • Type-safe (PHP 7.4+ type hints) and PHPStan-compatible, reducing false positives in static analysis.

Technical Risk

Risk Area Assessment Mitigation
Behavioral Changes Minor edge-case fixes (e.g., Windows paths in 3.0.0) were reverted in 3.0.1+. No breaking changes in 3.0.x. Test thoroughly against existing URI logic (e.g., parse_url(), Laravel’s url() helper) to validate consistency.
Performance Overhead Negligible (pure-PHP, no external calls). Benchmark against native parse_url() for critical paths (e.g., request routing). Profile in staging with real-world URI payloads (e.g., user-generated links, API endpoints).
Unicode/Internationalization Handles non-ASCII characters correctly (e.g., Chinese/Hebrew URLs via RFC3986 compliance). Validate against multilingual test cases (e.g., Laravel’s localization features).
Windows Path Support Special handling for file:///C:/ paths (fixed in 2.2.4/3.0.1). Test with Windows-based storage integrations (e.g., S3, local filesystem drivers).
Static Analysis PHPStan 2+ support reduces false positives but may require minor type adjustments in calling code. Audit existing URI logic for type mismatches (e.g., null returns from parse()).
Long-Term Maintenance Community-driven (fruux) with infrequent releases (last update: 2026-04-01). No active Laravel-specific support, but no Laravel dependencies. Monitor GitHub issues for critical bugs. Consider forking if maintenance becomes a blocker (low risk given stability).

Key Questions for the TPM

  1. Use Case Prioritization:
    • Which specific URI edge cases does the team currently handle manually? (e.g., Windows paths, relative resolution, Unicode).
    • Are there security-sensitive features (e.g., open redirect prevention, OAuth flows) where RFC3986 compliance is critical?
  2. Integration Scope:
    • Should this replace all URI parsing in Laravel (e.g., parse_url(), Str::of()) or only specific components (e.g., API request validation)?
    • How will it interact with Laravel’s routing system (e.g., normalizing incoming URIs before Route::dispatch)?
  3. Testing Strategy:
    • What existing URI tests (if any) should be migrated to use sabre/uri?
    • Should we benchmark against native parse_url() for performance-critical paths (e.g., request routing)?
  4. Deprecation Plan:
    • If adopting, should we deprecate custom URI logic in phases (e.g., mark as @deprecated in 1–2 releases)?
    • How will this affect legacy PHP 7.4–8.1 systems (if any)?
  5. Tooling Impact:
    • Will PHPStan’s stricter URI validation (via this package) reduce false positives in CI/CD?
    • Should we update Rector rules to migrate from parse_url() to sabre/uri incrementally?

Integration Approach

Stack Fit

  • Laravel Core:
    • Request Handling: Replace or extend Illuminate\Http\Request URI parsing (e.g., normalize incoming URIs before routing).
    • Routing: Use normalize() to canonicalize route URIs (e.g., /user/1 vs. /user/1/).
    • Storage: Resolve file:// or s3:// URIs in filesystem drivers (e.g., Storage::disk()).
  • APIs/Webhooks:
    • Validate incoming webhook URIs (e.g., resolve() relative paths against a base URL).
    • Normalize API endpoints for caching (e.g., /v1/endpoint vs. /v1/endpoint/).
  • User-Generated Content:
    • Sanitize URLs in CMS posts, forum links, or user profiles (e.g., normalize() for consistent storage).
  • Authentication:
    • Handle OAuth redirects or open redirect prevention (e.g., parse() to validate URI structure).

Migration Path

Phase Action Tools/Dependencies
Assessment Audit existing URI logic (e.g., parse_url(), custom functions) for edge cases (Windows paths, Unicode, relative resolution). phpstan, robo (for static analysis), manual code review.
Pilot Integration Replace one high-impact component (e.g., API request validation or storage URI resolution) with sabre/uri. Laravel’s app/Providers/AppServiceProvider (bind sabre/uri as a singleton).
Core Integration Extend Laravel’s Request class to use sabre/uri for URI parsing (e.g., override getRequestUri()). Laravel’s Illuminate\Http\Request facade.
Testing Write RFC3986-compliant test cases for all URI operations (e.g., resolve(), normalize()). PestPHP or PHPUnit, sabre/uri test suite as reference.
Deprecation Mark custom URI functions as @deprecated and replace them in 2–3 releases. Laravel’s deprecation helper.
Optimization Benchmark against native parse_url() and optimize critical paths (e.g., caching parsed URIs in Request). Laravel’s Benchmark facade or Blackfire.

Compatibility

  • Laravel-Specific:
    • No conflicts with Laravel’s core (dependency-free).
    • Works with:
      • Laravel’s url() helper (for building URIs from parsed components).
      • Storage facade (for resolving file:// or s3:// URIs).
      • Route model binding (for normalizing route parameters).
    • Potential Overrides:
      • Extend Illuminate\Http\Request to use sabre/uri for getRequestUri().
      • Override Illuminate\Support\Str::of() for URI-specific logic.
  • PHP Extensions:
    • No dependencies on intl or mbstring (handles Unicode via RFC3986).
    • Works with PHP 8.5’s typed properties (no runtime issues).
  • Third-Party:
    • No known conflicts with popular Laravel packages (e.g., Spatie, Laravel Excel).
    • Avoid if: Using a URI library with incompatible parsing rules (e.g., custom parse_url() wrappers).

Sequencing

  1. Phase 1: Low-Risk Adoption (1–2 weeks)
    • Replace custom URI parsing in non-critical components (e.g., CMS plugins, background jobs
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport