PHP code example of httpsoft / http-emitter

1. Go to this page and download the library: Download httpsoft/http-emitter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

httpsoft / http-emitter example snippets


use HttpSoft\Emitter\SapiEmitter;
use Psr\Http\Message\ResponseInterface;

/** @var ResponseInterface $response */
$response->getBody()->write('Content');

$emitter = new SapiEmitter();
$emitter->emit($response);
// Output result: 'Content'

$emitter = new SapiEmitter(8192);
$emitter->emit($response);
// Output result: 'Content'

$emitter = new SapiEmitter(8192);
$emitter->emit($response->withHeader('Content-Range', 'bytes 0-3/7'));
// Output result: 'Cont'

$emitter = new SapiEmitter(8192);
$emitter->emit($response, true);
// Output result: ''