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 Message Implementation

Http Message Implementation Laravel Package

psr-mock/http-message-implementation

Lightweight PSR-7 HTTP message implementation mock for testing libraries and SDKs without hard dependencies. Strictly follows PSR behavior and includes a developer-friendly API to debug and fix failing tests faster. For dev use only (PHP 8.1+).

View on GitHub
Deep Wiki
Context7

Lightweight mocking library for PSR-7 HTTP Message implementations, tailor-made to help you create test suites that are easier to write and maintain.

Frequently asked questions about Http Message Implementation
Can I use this package for testing Laravel HTTP clients like Guzzle or Symfony HTTP Client?
Yes, this package is designed for testing PSR-7-compliant HTTP clients in Laravel. It provides mock implementations of `Request`, `Response`, and other PSR-7 interfaces, which work seamlessly with Guzzle, Symfony HTTP Client, and Laravel’s built-in HTTP layer. The strict PSR-7 compliance ensures compatibility with Laravel’s HTTP middleware and request/response handling.
What Laravel versions does this package support?
This package requires PHP 8.1+, which aligns with Laravel 9+ and newer. If you’re using Laravel 8.x (PHP 7.4+), this package won’t work due to the PHP version requirement. For Laravel 8.x, consider alternatives like `php-mock/psr7-mock` or stick with Laravel’s built-in mocking utilities.
How do I install this package for Laravel testing?
Install it as a dev dependency via Composer: `composer require --dev psr-mock/http-message-implementation`. It’s not meant for production—only for testing environments. The package integrates cleanly with PHPUnit or Pest for writing HTTP-related tests in Laravel.
Does this package support Laravel-specific HTTP features like UploadedFile or signed requests?
While the package strictly follows PSR-7, Laravel’s extensions (e.g., `UploadedFile`, signed requests, or `Jsonable` traits) may require additional handling due to PHP 8.1’s stricter typing. Test edge cases like file uploads or custom headers to ensure compatibility, especially if your Laravel app relies on these features.
Will this package work with PHPUnit or Pest in Laravel?
Yes, it’s fully compatible with PHPUnit and Pest. The package provides a developer-friendly API for creating and debugging mock HTTP messages, which integrates smoothly with Laravel’s testing frameworks. PHP 8.1’s features (like named arguments) may simplify mock assertions in newer test suites.
Are there any known conflicts with other PSR-7 libraries like nyholm/psr7?
While conflicts are rare, PHP 8.1’s stricter autoloading and type system may reduce ambiguity in version mismatches. Ensure your `composer.json` doesn’t force conflicting versions of PSR-7 libraries. If you encounter issues, check for version constraints or use `replace` directives in Composer.
How does this package handle edge cases like streaming responses or custom headers?
The package adheres strictly to PSR-7, so it supports streaming responses and custom headers as defined by the spec. However, PHP 8.1’s type system may enforce stricter validation (e.g., headers must be `string[]`). Test these scenarios early, especially if your Laravel app relies on non-standard HTTP behaviors.
Can I use this in CI/CD pipelines for Laravel tests?
Yes, but your CI must use PHP 8.1+. Since this is a dev-only package, it won’t affect production builds. Update your CI configuration to enforce PHP 8.1+ and install the package as a dev dependency. No additional runtime dependencies are required.
What alternatives exist for Laravel HTTP mocking if PHP 8.1 isn’t an option?
For Laravel 8.x (PHP 7.4+), consider `php-mock/psr7-mock` or Laravel’s built-in mocking utilities. If you’re stuck on PHP 7.4, you may also use `mockery/mockery` or manually create mocks with PHPUnit’s `createMock()` method, though these lack the developer-friendly API of this package.
How do I debug failing tests with this package?
The package includes a developer-friendly API to inspect mock HTTP messages, making it easier to debug test failures. Use methods like `getHeaders()`, `getBody()`, or `getUri()` to inspect the mock state. PHP 8.1’s error handling will also surface type-related issues early, helping you fix problems faster.
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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours