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

Http Factory Implementation Laravel Package

psr-mock/http-factory-implementation

Lightweight PSR-17/PSR-7 HTTP factory/message mock implementation for PHP 8.1+. Built for SDKs and libraries to test against PSR interfaces without hard deps, with strict PSR compliance and helpful debugging API.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Testability & Developer Experience: Enables rapid, maintainable unit/integration tests for HTTP-related components (e.g., message factories, request/response objects) by reducing boilerplate in mock creation. Aligns with a "shift-left" testing strategy, improving CI/CD pipeline efficiency. Updated: Now requires PHP 8.1+, ensuring compatibility with modern Laravel (v9+) and PHP ecosystems, reducing legacy maintenance overhead.
  • PSR Compliance Roadmap: Supports adoption of PSR-7/PSR-17 standards, reducing vendor lock-in and easing future migrations to frameworks like Symfony, Slim, or Laminas. Updated: PHP 8.1+ alignment ensures seamless integration with newer PSR-compliant tools and Laravel’s evolving stack.
  • Build vs. Buy: Justifies not building custom mocking utilities for HTTP layers, saving dev time and reducing technical debt. Ideal for teams already using PSR-compliant HTTP stacks (e.g., Guzzle, Nyholm PSR7). Updated: PHP 8.1+ requirement filters out older, unsupported environments, streamlining adoption for modern teams.
  • Use Cases:
    • Testing middleware (e.g., auth, rate-limiting) without external dependencies.
    • Mocking HTTP clients/server responses in isolated unit tests.
    • Simplifying contract testing for APIs or microservices.
    • New: Ideal for Laravel 9+ projects or teams upgrading to PHP 8.1+.

When to Consider This Package

  • Adopt if:

    • Your stack uses PSR-7 HTTP Messages (e.g., Guzzle, Nyholm PSR7, Slim) or PSR-17 Factories.
    • You prioritize test speed/maintainability over minimalist mocking (e.g., prefer readability over one-liners like Mockery).
    • Your team lacks dedicated mocking libraries (e.g., PHPUnit’s createMock() is cumbersome for HTTP objects).
    • You’re building API clients, middleware, or HTTP-based services where mocking is frequent.
    • Updated: Your project runs on PHP 8.1+ (e.g., Laravel 9+, Symfony 6+, or modern PHP stacks).
    • You’re migrating from older PHP versions and want to align with current best practices.
  • Look elsewhere if:

    • You need advanced mocking (e.g., behavior verification, partial mocks) → Use Mockery or PHPUnit.
    • Your HTTP layer is non-PSR-compliant (e.g., legacy Symfony 1.x, custom implementations).
    • You’re in a performance-critical path (this is a testing tool, not a prod dependency).
    • Your team prefers data-driven testing (e.g., factories like Faker or Laravel’s Factory Pattern).
    • Updated: You’re stuck on PHP < 8.1 (e.g., Laravel 8.x or older) and lack plans to upgrade soon.

How to Pitch It (Stakeholders)

To Executives: "This lightweight library cuts test development time by 30%+ for HTTP-related components, reducing flaky tests and accelerating feature delivery. By standardizing mock creation for PSR-7/PSR-17, we future-proof our codebase for framework-agnostic HTTP tools—saving costs on custom solutions and easing tech stack upgrades. Updated: Now requires PHP 8.1+, ensuring compatibility with modern Laravel (v9+) and reducing long-term maintenance costs for legacy systems."

To Engineering: *"Imagine writing tests like this:

$mockFactory = new PsrMockHttpFactory();
$request = $mockFactory->createRequest('GET', '/users');
$response = $mockFactory->createResponse(200)->withBody('{"id":1}');

No more wrestling with Mockery for simple HTTP objects. Updated: Now works seamlessly with PHP 8.1+ and Laravel 9+, making it the go-to for testing middleware, API clients, or PSR-compliant services. Zero dependencies, MIT-licensed, and actively maintained—just install, use, and focus on logic. Note: Requires PHP 8.1+; ideal for modern stacks."*

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
andydefer/laravel-cluster
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