https://github.com/jasny/http-message-php-ext
PSR-7 implementation as PHP extension (pecl)
https://github.com/jasny/http-message-php-ext
pecl php psr-7
Last synced: 11 months ago
JSON representation
PSR-7 implementation as PHP extension (pecl)
- Host: GitHub
- URL: https://github.com/jasny/http-message-php-ext
- Owner: jasny
- License: mit
- Created: 2019-05-02T11:35:52.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-12-13T07:06:19.000Z (over 4 years ago)
- Last Synced: 2025-02-06T21:55:27.166Z (over 1 year ago)
- Topics: pecl, php, psr-7
- Language: PHP
- Size: 320 KB
- Stars: 20
- Watchers: 5
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# PSR-7 HTTP Message as PHP extension
[](https://travis-ci.org/improved-php-library/http-message)
[](https://ci.appveyor.com/project/jasny/http-message/branch/master)
[PSR-7 HTTP Message](https://www.php-fig.org/psr/psr-7/) implementation as PHP extension written in C. Includes a
[PSR-17](https://www.php-fig.org/psr/psr-17/) compatilbe factory and an emitter.
---
## Requirements
* PHP 7.2+
* [psr extension](https://github.com/jbboehr/php-psr)
## Installation
The extension is [available from pecl](https://pecl.php.net/package/http_message).
pecl install psr
pecl install http_message-beta
### Manual build
Instead of installing this extension from pecl, you can build it manually
phpize
./configure
make
make test
make install
Add the following line to your `php.ini`
extension=http_message.so
To try out the extension, you can run the following command
php -a -d extension=modules/http_message.so
# Usage
```php
use HttpMessage\Emitter;
use HttpMessage\Factory;
use HttpMessage\ServerRequest;
$request = new ServerRequest($_SERVER, $_COOKIE, $_GET, $_POST, $_FILES);
$handler = new App\Psr15Handler(); // Any PSR-15 handler.
$response = $handler->handle($request);
$emitter = new Emitter();
$emitter->emit($response);
```