PHP code example of syberisle / mock-php-stream

1. Go to this page and download the library: Download syberisle/mock-php-stream 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/ */

    

syberisle / mock-php-stream example snippets


MockPhpStream::register();
file_put_contents('php://input', 'you test data');

$app = new Slim\App();
$app->post('', function ($request) {
    // direct file uploads
    $request->getBody()->detach();
    $from = fopen("php://input", 'r');
    $to   = fopen('/my/path/file', 'w');
    stream_copy_to_stream($from, $to);
    fclose($from);
    fclose($to);
});

MockPhpStream::unregister();