Download the PHP package solophp/http-emitter without Composer
On this page you can find all versions of the php package solophp/http-emitter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package http-emitter
HTTP-Emitter
PSR-7 HTTP Response Emitter for PHP 8.1+. Implements Solo\Contracts\Http\EmitterInterface, so it plugs straight into solophp/application.
Installation
Usage
The body is streamed in chunks of 4096 bytes. Pass another size to the constructor if you need to:
With solophp/application
Register the emitter in a service provider:
Application::run() resolves EmitterInterface from the container and emits the response returned by the middleware pipeline.
Behavior
- The status line is sent after the headers, so a
Locationheader can't reset the status code to302 - Repeated header values are sent as separate headers;
Set-Cookienever replaces cookies that were already set - Seekable bodies are rewound before output
- A valid
Content-Lengthheader limits how many body bytes are sent; otherwise the body is read to the end - No body is sent for
1xx,204,205and304responses - Output stops early if the client disconnects
- If headers were already sent, only the body is emitted
Production notes
- Keep
display_errorsoff. Any output beforeemit()(a warning, a BOM or blank line before<?php, a strayecho) makes PHP send its default headers early, and the emitter can then only send the body emit()runs after the middleware pipeline, so error-handling middleware doesn't see failures while the body is read. By then the headers are out; log such errors with a global exception handler- HEAD requests need no special handling: PHP drops the body of a HEAD response itself, including routes that fall back from HEAD to GET
- Bodies are sent in chunks, so memory use stays flat for large responses, unless
emit()runs inside anob_start()without a chunk size
Requirements
- PHP ^8.1
- PSR HTTP Message ^1.1|^2.0
- solophp/contracts ^1.1
Testing
License
MIT
All versions of http-emitter with dependencies
PHP Build Version
Package Version
The package solophp/http-emitter contains the following files
Loading the files please wait ...