Weave 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

Http Laravel Package

psr-mock/http

psr-mock/http is a tiny PHP package for mocking PSR-7 HTTP messages in tests. Create predictable request/response objects without a full HTTP client, helping you unit test middleware, clients, and services with minimal setup.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Accelerated Test Development: Enables rapid creation of unit tests for HTTP-related components (e.g., middleware, API handlers) without relying on external services or complex mocking frameworks, reducing test setup time by ~30%.
  • Middleware & Handler Testing: Critical for validating PSR-15 middleware or PSR-7-compliant request/response pipelines, ensuring consistency in edge cases (e.g., malformed headers, large payloads).
  • Build vs. Buy: Justifies not building a custom mocking solution when PSR-7 interoperability is required, saving dev time and maintenance overhead.
  • Roadmap for API-First Products: Supports scaling test coverage for microservices or APIs where HTTP message fidelity is critical (e.g., validating OAuth flows, rate-limiting logic).
  • Performance Testing: Allows generating synthetic HTTP traffic for load-testing middleware or handlers without external dependencies (e.g., simulating 10K requests/sec in isolation).

When to Consider This Package

  • Adopt when:

    • Your stack uses PSR-7 (e.g., Slim, Laminas, Symfony HTTP components) and requires unit-testable HTTP messages.
    • You need lightweight, dependency-free mocks (no Guzzle, React, or monolithic frameworks).
    • Testing middleware, request/response transformers, or validation logic (e.g., CORS, auth headers).
    • Your CI/CD pipeline prioritizes fast, isolated tests (avoiding HTTP server spin-up delays).
  • Look elsewhere if:

    • You require mocking HTTP clients (e.g., Guzzle requests) → Use mockery + GuzzleHttp/Handler.
    • Your tests need real HTTP interactions (e.g., API contracts) → Use VCR or Pest HTTP tests.
    • You’re using non-PSR-7 HTTP libraries (e.g., Symfony’s Request/Response directly) → Check for native mocking tools.
    • You need advanced HTTP protocol features (e.g., WebSockets, HTTP/2) → Consider ReactPHP or Swoole mocks.

How to Pitch It (Stakeholders)

For Executives: "This package lets our team write faster, more reliable tests for HTTP logic—critical for APIs and middleware—without adding bloat. By mocking requests/responses in-memory, we cut test setup time by ~30%, accelerating feature delivery and reducing flaky CI failures. It’s a lightweight, PSR-compliant solution that aligns with our PHP ecosystem and avoids vendor lock-in."

For Engineering: *"psr-mock/http gives us a zero-config way to generate PSR-7 requests/responses for unit tests. Key benefits:

  • No external servers: Test middleware or handlers instantly (e.g., mockRequest()->withHeader('X-API-Key', '123')).
  • Edge-case coverage: Easily simulate malformed payloads, custom status codes, or cookies.
  • Minimal footprint: MIT-licensed, 1 dependency, and focused only on test ergonomics. Perfect for validating auth logic, rate-limiting, or API gateways—just add it to your composer.json and start mocking."
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.
andydefer/laravel-notification
adachsoft/cli-process-tester
jhaskell13/laraflow
sebastienheyd/boilerplate-media-manager
ccast/tagixo-primix
pretendtrue/laravel-builder
sawmainek/laravel-scout-tntsearch-driver
tomshaw/laravel-calendar-table
dibakar/laravel-ownership
steadrun/laravel-monitor
labyrinthe/connect-laravel
elmogy/layan
drewdan/sentinel-client
dskripchenko/laravel-llm
fatryst/nuonuo
stevenay/myanfont
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc