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

Message Factory Laravel Package

php-http/message-factory

Legacy PSR-7 HTTP message factory for PHP. Supports creating PSR-7 compliant HTTP messages (Request, Response, Stream, etc.) with ease. Maintains backward compatibility for existing codebases while encouraging migration to PSR-17 factories (now standard in major clients like Guzzle, Symfony HTTP Cli...

View on GitHub
Deep Wiki
Context7

Getting Started

This package is archived and obsolete, superseded by PSR-17. You should only install it (composer require php-http/message-factory) if you're maintaining legacy code that depends on PHP-HTTP's pre-PSR-17 factory interfaces (e.g., older versions of Guzzle adapters, Symfony HttpClient < 5, or custom code using Http\Message\Factory\RequestFactory). First, check if your HTTP client library already provides PSR-17 factories — most modern libraries (Guzzle, Symfony HttpClient, HTTPlug, etc.) do. If you must use this package, start by reading its README and the official docs at http://docs.php-http.org — but prioritize migrating to psr/http-factory implementations like nyholm/psr7 or guzzlehttp/psr7 with their built-in PSR-17 factories.

Implementation Patterns

In legacy codebases, developers typically used this package to:

  • Inject factory interfaces (e.g., Http\Message\Factory\RequestFactory, Http\Message\Factory\ResponseFactory) into services needing to construct PSR-7 messages without coupling to a specific implementation.
  • Leverage message factory adapters like php-http/guzzle6-adapter or php-http/curl-client, which internally depend on this package to provide PSR-7 message creation logic compatible with older HTTPlug versions.
  • Wrap external message creation (e.g., from Guzzle) via factory autowiring, using service container bindings like Http\Message\FactoryInterface.

Today, the recommended migration pattern is:

// Legacy (with message-factory)
$request = $requestFactory->createRequest('GET', 'https://example.com');

// Modern (with PSR-17)
use Nyholm\Psr7\Factory\Psr17Factory;
$psr17Factory = new Psr17Factory();
$request = $psr17Factory->createRequest('GET', 'https://example.com');

Always prefer injecting Psr\Http\Factory\ServerRequestFactoryInterface, RequestFactory, etc., and use widely supported implementations like nyholm/psr7 or laminas/laminas-diactoros.

Gotchas and Tips

  • ⚠️ No active development: Do not use in new projects. PSR-17 has been available since PHP 7.0 (2015) and adopted broadly since ~2018. This package only exists for backwards compatibility.
  • If you see interfaces like Http\Message\Factory\RequestFactory, double-check your dependencies — they likely stem from outdated HTTPlug or Symfony components. Update to Symfony HttpClient 5+ or use PSR-17 directly.
  • The package does support both PSR-7 v1 and v2 (psr/http-message:^1.0 || ^2.0), but mismatched PSR-7 versions in your stack can cause runtime errors. Verify all dependencies use the same PSR-7 version.
  • Service containers sometimes bind the old Http\Message\FactoryInterface aliases — review service definitions for deprecated bindings and replace them with PSR-17 equivalents (e.g., Psr\Http\Message\ServerRequestFactoryInterface).
  • When debugging, remember: this package only defines interfaces — actual instantiation happens in adapter implementations (e.g., php-http/message, php-http/guzzle6-adapter). Check those for factory logic if error messages reference factory methods.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport