PHP code example of clue / zlib-react

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

    

clue / zlib-react example snippets


$stream = new React\Stream\ReadableResourceStream(fopen('access.log.gz', 'r'));

$decompressor = new Clue\React\Zlib\Decompressor(ZLIB_ENCODING_GZIP);
$stream->pipe($decompressor);

$decompressor->on('data', function ($data) {
    echo $data; // chunk of decompressed log data
});

$encoding = ZLIB_ENCODING_GZIP; // or ZLIB_ENCODING_RAW or ZLIB_ENCODING_DEFLATE
$compressor = new Clue\React\Zlib\Compressor($encoding);

$compressor->on('data', function ($data) {
    echo $data; // compressed binary data chunk
});

$compressor->write($uncompressed); // write uncompressed data chunk

$input->pipe($filterBadWords)->pipe($compressor)->pipe($output);

$encoding = ZLIB_ENCODING_GZIP; // or ZLIB_ENCODING_RAW or ZLIB_ENCODING_DEFLATE
$decompressor = new Clue\React\Zlib\Decompressor($encoding);

$decompressor->on('data', function ($data) {
    echo $data; // decompressed data chunk
});

$decompressor->write($compressed); // write compressed binary data chunk

$input->pipe($decompressor)->pipe($filterBadWords)->pipe($output);