PHP code example of wyrihaximus / react-stream-base64

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


$streamToDecode = new ThroughStream();
$stream = new ReadableStreamBase64Decode($streamToDecode);
$stream->on('data', function ($data) {
    echo $data; // foo.bar
});
$streamToDecode->write('Zm9vLmJhcg==');

$streamToEncode = new ThroughStream();
$stream = new ReadableStreamBase64Encode($streamToEncode);
$stream->on('data', function ($data) {
    echo $data; // Zm9vLmJhcg==
});
$streamToEncode->write('foo.bar');

$streamToDecode = new ThroughStream();
$stream = new WritableStreamBase64Decode($streamToDecode);
$stream->write('Zm9vLmJhcg=='); // Writes foo.bar to $streamToDecode

$streamToEncode = new ThroughStream();
$stream = new WritableStreamBase64Encode($streamToEncode);
$stream->write('foo.bar'); // Writes Zm9vLmJhcg== to $streamToEncode