PHP code example of wyrihaximus / react-stream-json

1. Go to this page and download the library: Download wyrihaximus/react-stream-json 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/ */

    

wyrihaximus / react-stream-json example snippets


$stream = new ThroughStream();
$anotherStream = new ThroughStream();

$jsonStream = new JsonStream();
$jsonStream->end([
    'key' => 'value',
    'promise' => resolve('value'),
    'stream' => $stream,
    'nested' => [
        'a' => 'b',
        'c' => 'd',
    ],
    'nested_promises' => [
        resolve('first'),
        resolve('second'),
    ],
    'nested_mixed' => [
        'first',
        resolve($anotherStream),
        resolve('third'),
    ],
]);

$stream->end('stream contents');
$anotherStream->end('second');