php-http/mock-client
Mock HTTP client for HTTPlug/PHP-HTTP. Stores outgoing requests and returns queued responses or throws exceptions instead of making real network calls—ideal for unit tests of HTTP-dependent code. Install via Composer as a dev dependency.
Architecture fit is strong due to Laravel's native PSR-18 compliance via Guzzle, making this mock client a natural fit for HTTP-related tests. Integration feasibility is high—Laravel's service container allows seamless replacement of the HTTP client with the mock during testing via simple binding. Technical risk is low as it's purely a test utility with no production surface area, though minor risks exist around edge cases in middleware handling or async request simulations if Laravel's HTTP client usage deviates from standard PSR-18 behavior. Key questions include: How does it interact with Laravel's built-in HTTP client middleware? Does it support Laravel-specific test contexts (e.g., database transactions)? What version compatibility exists with Laravel's HTTP client implementation?
Stack fit is excellent—Laravel's default HTTP client (Guzzle) is PSR-18-compliant, and the mock client works directly with PHPUnit/Pest test suites without additional tooling. Migration path requires minimal effort: bind the MockClient to the Http\Client interface in test environment service providers, then queue responses/exceptions in test setup blocks. Compatibility is near-perfect for standard Laravel HTTP usage, though custom Guzzle client configurations (e.g., non-standard handlers) may require validation. Sequencing involves: (1) configuring mock responses in test setup, (2) injecting the mock into the container, (3) executing tests where HTTP calls are intercepted, and (4) asserting request patterns via the mock's inspection methods.
Maintenance is negligible—minimal code footprint and MIT licensing eliminate ongoing overhead, though low community adoption (71 stars) may slow issue resolution for niche scenarios. Support relies primarily on documentation since community channels are limited,
How can I help you explore Laravel packages today?