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

Unaltered Psr Http Message Bridge Bundle Laravel Package

loophp/unaltered-psr-http-message-bridge-bundle

Symfony bundle bridging PSR-7 HTTP messages without altering them. Converts between PSR-7 requests/responses and Symfony HttpFoundation safely, preserving headers, body streams, and URIs—useful when integrating PSR-7 middleware or clients in Symfony apps.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • PSR-7/PSR-17 Compatibility: The package bridges PSR-7 HTTP messages (requests/responses) to Symfony’s native Request/Response objects without modifying query parameters, aligning well with Laravel’s PSR-15 middleware stack (via symfony/http-foundation bridge). However, Laravel’s native Illuminate\Http\Request/Response are not PSR-7 compliant by default, requiring explicit integration.
  • Use Case Alignment: Ideal for scenarios where PSR-7 compliance is required (e.g., integrating with PSR-15 middleware, HTTP clients like Guzzle, or frameworks like Slim/Lumen) while preserving query parameters (unlike Symfony’s default bridge, which may normalize them).
  • Laravel-Specific Gaps: Laravel’s Request object extends Symfony\Component\HttpFoundation\Request, which already has a PSR-7 bridge (symfony/http-foundation-bridge). This package may be redundant unless query parameter preservation is critical for a specific workflow (e.g., API gateways, proxy services).

Integration Feasibility

  • Core Laravel Integration:
    • Middleware: Can be used to convert incoming Illuminate\Http\Request to PSR-7 Psr\Http\Message\RequestInterface for PSR-15 middleware processing, then revert to Laravel’s format downstream.
    • HTTP Clients: Useful for outbound requests (e.g., Guzzle) where PSR-7 messages are required but query parameters must remain unaltered.
    • Service Containers: Compatible with Laravel’s DI container via Symfony’s Bridge component, but explicit binding may be needed.
  • Dependencies:
    • Requires psr/http-message (^1.0), symfony/http-foundation (^5.0|^6.0), and symfony/dependency-injection (^5.0|^6.0).
    • Laravel’s default symfony/http-foundation-bridge may conflict; dependency resolution must ensure no version clashes.
  • Query Parameter Handling: The package’s primary value is preserving query parameters during PSR-7 conversions. Laravel’s default bridge may strip or normalize them (e.g., converting arrays to strings), making this package useful for edge cases like:
    • API proxies where raw query strings must be forwarded.
    • Integration with tools expecting unmodified query parameters (e.g., analytics, A/B testing).

Technical Risk

  • Version Lock: Last release in 2022 with no recent activity. Risk of compatibility issues with Laravel 10+ or Symfony 6.4+.
  • Redundancy: Overlap with Laravel’s built-in symfony/http-foundation-bridge. Justification for adoption must address specific query parameter requirements.
  • Testing Overhead: Requires thorough testing to ensure:
    • No regression in Laravel’s native request/response handling.
    • Correct behavior with complex query parameters (e.g., nested arrays, special characters).
  • Performance Impact: Minimal, but additional conversions (Laravel ↔ PSR-7 ↔ Laravel) may introduce latency in high-throughput systems.

Key Questions

  1. Why Not Use Laravel’s Native Bridge?
    • Are there documented cases where symfony/http-foundation-bridge alters query parameters in ways this package avoids?
  2. Use Case Specificity:
    • Is this for inbound requests (e.g., API gateway), outbound requests (e.g., HTTP clients), or both?
  3. Dependency Conflicts:
    • How will this package coexist with Laravel’s existing symfony/http-foundation version?
  4. Long-Term Maintenance:
    • Is the package’s stagnation acceptable, or is a maintained alternative (e.g., custom bridge) preferable?
  5. Testing Strategy:
    • How will query parameter preservation be validated across edge cases (e.g., UTF-8, reserved characters)?

Integration Approach

Stack Fit

  • Laravel Compatibility:
    • Inbound: Works with Laravel’s Kernel middleware stack if wrapped in a PSR-15 middleware adapter (e.g., league/route or brick/route).
    • Outbound: Directly usable with Guzzle or other PSR-17 HTTP clients.
  • Symfony Integration:
    • Leverages Symfony’s HttpFoundation bridge, so existing Symfony components (e.g., HttpClient) will integrate seamlessly.
  • Alternatives:
    • For Laravel-only projects, consider extending symfony/http-foundation-bridge instead of introducing a new dependency.
    • For PSR-15 middleware, evaluate php-http/dispatcher or league/route for broader compatibility.

Migration Path

  1. Assessment Phase:
    • Audit current request/response handling to identify where query parameter preservation is critical.
    • Test against Laravel’s default bridge to confirm deviations.
  2. Dependency Setup:
    • Add to composer.json:
      "require": {
          "loophp/unaltered-psr-http-message-bridge-bundle": "^1.0"
      }
      
    • Resolve Symfony version conflicts via platform or conflict constraints.
  3. Integration Points:
    • Middleware:
      // Example: Convert Laravel Request to PSR-7 for PSR-15 middleware
      $psrRequest = (new UnalteredBridge())->toPsr7($request);
      $response = $psr15Middleware->process($psrRequest, $handler);
      $laravelResponse = (new UnalteredBridge())->toHttpFoundation($response);
      
    • HTTP Clients:
      $client = new GuzzleClient();
      $psrRequest = (new UnalteredBridge())->toPsr7($request);
      $response = $client->sendRequest($psrRequest);
      
  4. Service Provider:
    • Bind the bridge to Laravel’s container (if not auto-discovered):
      $this->app->bind(\Psr\Http\Message\RequestInterface::class, function ($app) {
          return (new UnalteredBridge())->toPsr7($app->make(\Illuminate\Http\Request::class));
      });
      

Compatibility

  • Laravel Versions:
    • Tested with Laravel 8/9 (via Symfony 5/6). Laravel 10 may require adjustments due to Symfony 6.4+ changes.
  • Query Parameter Edge Cases:
    • Validate with:
      • Multidimensional arrays (?foo[bar]=baz).
      • Special characters (?query=hello%20world).
      • Reserved characters (?query=foo&query=bar).
  • Middleware Stack:
    • Ensure PSR-15 middleware does not expect Laravel-specific features (e.g., request()->input()).

Sequencing

  1. Phase 1: Pilot in a non-critical endpoint to validate query parameter behavior.
  2. Phase 2: Integrate with HTTP clients (e.g., Guzzle) for outbound requests.
  3. Phase 3: Roll out to middleware stack if inbound use case is confirmed.
  4. Phase 4: Monitor for performance regressions or query parameter corruption.

Operational Impact

Maintenance

  • Dependency Risks:
    • Stagnation: No updates since 2022. Plan for forks or custom patches if issues arise.
    • Symfony Major Versions: Upgrades to Symfony 7+ may break compatibility.
  • Laravel Updates:
    • Monitor for changes in Illuminate\Http\Request or symfony/http-foundation-bridge that could affect the bridge.
  • Documentation:
    • Limited documentation; expect to rely on source code or Symfony’s bridge docs for troubleshooting.

Support

  • Community:
    • Minimal stars/issues; support may require self-reliance or Symfony community input.
  • Debugging:
    • Use dd() or var_dump() to inspect PSR-7 ↔ Laravel conversions.
    • Log query parameters before/after conversion to catch regressions.
  • Fallback Plan:
    • Maintain a custom bridge as a backup if the package becomes unmaintainable.

Scaling

  • Performance:
    • Conversion overhead is negligible for most use cases, but benchmark in high-throughput scenarios (e.g., 10K+ RPS).
    • Consider caching PSR-7 conversions if the same request is reused (e.g., in middleware pipelines).
  • Resource Usage:
    • No significant memory/CPU impact expected, but validate with tools like Blackfire.
  • Horizontal Scaling:
    • Stateless conversions mean no additional load on distributed setups.

Failure Modes

  • Query Parameter Corruption:
    • Risk if the bridge mishandles encoding/decoding (e.g., + vs. %20 in queries).
    • Mitigation: Validate with a test suite covering edge cases.
  • Middleware Conflicts:
    • PSR-15 middleware expecting Laravel-specific features may fail.
    • Mitigation: Wrap conversions in try-catch blocks with fallback logic.
  • Dependency Blockers:
    • Version conflicts with symfony/http-foundation could halt deployment.
    • Mitigation: Use composer why-not to diagnose conflicts pre-integration.

**

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.
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime
canaltp/sam-ecore-application-manager-bundle
canaltp/sam-ecore-security-manager-bundle