PHP code example of appoly / zstd-php

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

    

appoly / zstd-php example snippets


use Appoly\ZstdPhp\ZSTD;

ZSTD::decompress('path/to/file.zst', 'path/to/output/file');

use Appoly\ZstdPhp\ZSTD;

ZSTD::compress('path/to/file', 'path/to/output/file.zst');

use Appoly\ZstdPhp\ZSTD;

$inputStream = fopen('path/to/file.zst', 'r');
$outputCallback = function ($outputChunk) {
    // Do something with the output chunk
    echo $outputChunk;
};

ZSTD::decompressDataFromStream(
    inputStream: $inputStream,
    outputCallback: $outputCallback
);

fclose($inputStream);

use Appoly\ZstdPhp\ZSTD;

$inputStream = fopen('path/to/file', 'r');
$outputCallback = function ($outputChunk) {
    // Do something with the output chunk
    echo $outputChunk;
};

ZSTD::compressDataToStream(
    inputStream: $inputStream,
    outputCallback: $outputCallback
);

fclose($inputStream);
bash
composer