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

Psr Http Message Bridge Bundle Laravel Package

loophp/psr-http-message-bridge-bundle

Symfony bundle that bridges PSR-7 HTTP messages with Symfony’s HttpFoundation, enabling smooth interop between PSR-7 libraries and Symfony apps. Provides converters/adapters to translate requests and responses in both directions.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony v8 Dependency Impact:

    • The package now requires Symfony 8.x (symfony/http-foundation:^8.0), which may conflict with Laravel’s default symfony/http-foundation:^6.3 (as of Laravel 10.x).
    • Laravel Compatibility Risk: Laravel’s symfony/http-foundation (v6.x) is not backward-compatible with Symfony 8.x’s breaking changes (e.g., HttpFoundation API adjustments, Stream interface changes).
    • Workaround: Requires dual dependency management (pinning symfony/http-foundation:^6.3 for Laravel core while injecting Symfony 8.x for the bundle), increasing complexity.
  • PSR-15/17 Stability:

    • Symfony 8.x’s PSR-17 implementations (e.g., RequestFactory, StreamFactory) are stable, but Laravel’s native Illuminate\Http may diverge in future versions.
    • Key Question: Does the project need Symfony 8.x-specific features (e.g., new UploadedFile methods), or is this a version lock-in risk?
  • Use Case Fit (Unchanged):

    • Still ideal for Symfony-to-Laravel migrations or projects requiring PSR-17 HTTP factories beyond Laravel’s native PSR-7 support.
    • Less critical if Laravel’s built-in Request/Response suffice or if php-http/message-factory is sufficient.

Integration Feasibility

  • Core Dependencies (Updated):

    • Breaking Change: symfony/http-foundation:^8.0 replaces v6.x, requiring:
      • Dependency Conflict Resolution: Use composer require symfony/http-foundation:^8.0 --with-all-dependencies in a separate namespace or via path aliases.
      • Service Provider Overrides: Laravel’s AppServiceProvider must explicitly bind Symfony 8.x factories to avoid conflicts with Laravel’s v6.x dependencies.
        $this->app->bind(\Symfony\Component\HttpFoundation\RequestFactory::class, function () {
            return new \Symfony\Component\HttpFoundation\RequestFactory(); // Symfony 8.x
        });
        
  • Key Challenges (Amplified):

    • Version Skew: Running two major versions of symfony/http-foundation in the same app introduces:
      • Class Loading Issues: Autoloader conflicts if not namespaced.
      • API Incompatibility: Symfony 8.x’s Stream or FileBag changes may break existing Laravel middleware.
    • Middleware Integration: PSR-15 middleware relying on Symfony 8.x’s HttpFoundation may fail if Laravel’s Illuminate\Http objects are passed (e.g., UploadedFile differences).
    • Testing Overhead: Tests assuming Symfony 6.x’s HttpFoundation will fail; mocking must account for v8.x changes.

Technical Risk

Risk Area Severity (Updated) Mitigation Strategy
Dependency Conflict Critical Isolate Symfony 8.x in a child namespace or use composer.json aliases.
API Breaking Changes High Test with Symfony 8.x’s HttpFoundation early; patch Laravel middleware.
Middleware Gaps Medium Implement dual-adapter middleware (handles both Laravel and Symfony objects).
Long-Term Maintenance High Monitor for Laravel 11+ or Symfony 8.x support in the bundle.
Composer Complexity Medium Use config.platform in composer.json to enforce version constraints.

Key Questions (Updated)

  1. Symfony 8.x Justification:
    • Are you leveraging Symfony 8.x-specific features (e.g., Stream improvements, UploadedFile changes), or is this a version lock-in?
  2. Dependency Isolation:
    • Can the team namespace-isolate Symfony 8.x dependencies, or will this require a monorepo or custom Composer scripts?
  3. Middleware Strategy:
    • Will PSR-15 middleware only process Symfony 8.x requests, or must it handle Laravel’s native Request objects? If the latter, a dual-adapter layer is mandatory.
  4. Fallback Plan:
    • If integration fails, is php-http/message-factory (PSR-17, Symfony-agnostic) a viable alternative?
  5. Team Bandwidth:
    • Does the team have experience resolving major version conflicts in symfony/http-foundation?

Integration Approach

Stack Fit (Updated)

  • Laravel + Symfony 8.x Compatibility Matrix:

    Laravel Version Symfony HTTP Foundation Conflict Level Notes
    10.x v6.x (default) High Symfony 8.x requires manual isolation.
    10.x v8.x (bundle) Critical Dependency collision without namespacing.
    11.x (future) v7.x/v8.x? Unknown Laravel may align with Symfony 8.x.
  • Key Components to Replace/Extend:

    • Symfony 8.x HttpFoundationFactory: Must be explicitly bound in Laravel’s container.
    • PSR-15 Middleware: Requires adapters to handle both Laravel Request and Symfony Request objects.
    • File Uploads: Symfony 8.x’s UploadedFile API differs from Laravel’s; middleware must normalize.

Migration Path (Updated)

  1. Phase 0: Dependency Isolation

    • Add Symfony 8.x to composer.json with a child namespace or config.platform:
      "config": {
        "platform": {
          "symfony/http-foundation": "8.0.0"
        }
      },
      "extra": {
        "symfony-8": {
          "directory": "vendor/symfony-8",
          "require": {
            "symfony/http-foundation": "^8.0"
          }
        }
      }
      
    • Run composer require symfony/http-foundation:^8.0 --with-all-dependencies --ignore-platform-reqs.
  2. Phase 1: Service Binding

    • Register Symfony 8.x factories in AppServiceProvider:
      use Symfony\Component\HttpFoundation\RequestFactory;
      use Symfony\Component\HttpFoundation\StreamedResponse;
      
      public function register() {
          $this->app->singleton(\Psr\Http\Message\RequestFactoryInterface::class, function () {
              return new RequestFactory(); // Symfony 8.x
          });
          $this->app->bind(StreamedResponse::class, function () {
              return new StreamedResponse(); // Symfony 8.x
          });
      }
      
  3. Phase 2: Dual Middleware Adapter

    • Create a PSR-15 middleware adapter that handles both Laravel and Symfony requests:
      use Psr\Http\Server\RequestHandlerInterface;
      use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
      use Illuminate\Http\Request as LaravelRequest;
      
      class DualRequestHandler implements RequestHandlerInterface {
          public function handle(SymfonyRequest|LaravelRequest $request, RequestHandlerInterface $handler) {
              $symfonyRequest = $request instanceof LaravelRequest
                  ? $this->toSymfonyRequest($request)
                  : $request;
              $response = $handler->handle($symfonyRequest, $handler);
              return $response;
          }
      
          protected function toSymfonyRequest(LaravelRequest $request) {
              // Convert Laravel Request to Symfony 8.x Request
              return RequestFactory::createFromGlobals()
                  ->duplicate([], [], $request->query->all(), $request->request->all(), $request->files->all(), $request->server->all());
          }
      }
      
  4. Phase 3: Testing

    • Mock Symfony 8.x objects in tests:
      $symfonyRequest = $this->createMock(SymfonyRequest::class);
      $symfonyRequest->method('getContent')->willReturn('test');
      
    • Test file uploads and streaming responses separately due to API changes.

Compatibility (Updated)

  • Pros:
    • Access to Symfony 8.x features (e.g., improved UploadedFile, Stream).
    • PSR-17 standardization for HTTP clients/middleware.
  • Cons:
    • Critical dependency conflicts without isolation.
    • Middleware complexity increases with dual-adapter logic.
    • Testing overhead for Symfony 8.x-specific edge cases (e.g., JsonResponse changes).
  • Fallback Options:
    • Abandon the bundle: Use Laravel’s native Request/Response (PSR-7) or `php-
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor