PHP code example of struggle-for-php / sfp-diactoros-extension

1. Go to this page and download the library: Download struggle-for-php/sfp-diactoros-extension 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/ */

    

struggle-for-php / sfp-diactoros-extension example snippets


// SapiEmitter
echo $response->getBody();

// SwitchingEmitter
if ($body instanceof FpassthruInterface) {
    $resource = $body->detach();
    if ($body instanceof RewindFpassthruInterface) {
        rewind($resource);
    }
    fpassthru($resource);
} else {
    echo $response->getBody();
}

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));