guzzlehttp / psr7
PSR-7 message implementation that also provides common utility methods
Requires
- php: ^7.4 || ^8.0
- psr/http-factory: ^1.1
- psr/http-message: ^2.0
- symfony/polyfill-php80: ^1.25
- symfony/polyfill-php82: ^1.27
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.8.2
- http-interop/http-factory-tests: 1.1.0
- jshttp/mime-db: 1.54.0.1
- php-http/psr7-integration-tests: ^1.5.1
- phpunit/phpunit: ^9.6.34
Suggests
- laminas/laminas-httphandlerrunner: Emit PSR-7 responses
Provides
This package is auto-updated.
Last update: 2026-07-20 13:49:26 UTC
README
guzzlehttp/psr7 is a PSR-7 HTTP message implementation for PHP. It provides
request, response, URI, uploaded file, and stream objects that work with Guzzle
and any other library using the PSR-7 interfaces.
Use this package directly when you need to create or inspect PSR-7 messages
without sending HTTP requests. If you only want to make HTTP requests, install
guzzlehttp/guzzle
instead; it already depends on this package.
Installation
composer require guzzlehttp/psr7
Version Guidance
| Version | Status | PHP Version |
|---|---|---|
| 3.0 | Latest | >=7.4,<8.6 |
| 2.13 | Maintenance | >=7.2.5,<8.6 |
| 1.9 | End of Life | >=5.4,<8.2 |
Quick Start
use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Utils; $request = new Request('GET', 'https://example.com/api'); $response = new Response(200, ['Content-Type' => 'text/plain'], 'OK'); $stream = Utils::streamFor('request or response body'); echo $request->getMethod(); echo $response->getStatusCode(); echo $stream;
PSR-7 messages and URIs are immutable. Methods such as withHeader() and
withUri() return a changed copy instead of modifying the original object.
Streams are mutable body handles; reading, writing, seeking, and closing a
stream can change its cursor, contents, or usability.
$request = $request->withHeader('Accept', 'application/json');
Documentation
- PSR-7 Messages
- Streams and Decorators
- URI Helpers
- PSR-17 Factories
- Message Helpers
- Diagnostic Values
- Header and Query Helpers
- Stream Helpers
- URI and MIME Helpers
- Upgrade Guide
- Changelog
Security
If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see Security Policy for more information.
License
Guzzle is made available under the MIT License (MIT). Please see License File for more information.
For Enterprise
Available as part of the Tidelift Subscription
The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.