struggle-for-php / sfp-diactoros-extension
An extension for zend-diactoros.
0.1.0
2015-06-05 15:58 UTC
Requires
- php: >=5.5.0
- lstrojny/phpunit-function-mocker: ~0.2.0
- zendframework/zend-diactoros: ~1.0
Requires (Dev)
- phpunit/phpunit: ~4.6
- squizlabs/php_codesniffer: ~2.0
This package is auto-updated.
Last update: 2024-12-06 16:06:34 UTC
README
A extension for zend-diactoros.
Feature
SfpDiactoros\Response\SwitchingEmitter
allows fpassthru()
with FpassthruInterface
.
just changed only in emitBody()
from original Zend\Diactoros\Response\SapiEmitter
.
// SapiEmitter echo $response->getBody();
// SwitchingEmitter if ($body instanceof FpassthruInterface) { $resource = $body->detach(); if ($body instanceof RewindFpassthruInterface) { rewind($resource); } fpassthru($resource); } else { echo $response->getBody(); }
Usage
use SfpDiactoros\Response\SwitchingEmitter; $server = Server::createServer($app, $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); $server->setEmitter(new SwitchingEmitter);
use SfpDiactoros\Stream\RewindFpassthruStream; $fp = fopen('/tmp/bigsize', 'r'); $response->withBody(new RewindFpassthruStream($fp));