PHP code example of syntaxx / lz4

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

    

syntaxx / lz4 example snippets


use Syntaxx\LZ4\LZ4;

// Create an instance
$lz4 = new LZ4();

// Compress data
$compressed = $lz4->compress($data);

// Decompress data
$decompressed = $lz4->decompress($compressed, $originalSize);

use Syntaxx\LZ4\LZ4;

// Create an instance
$lz4 = new LZ4();

// Compress data in chunks
$result = $lz4->compressPackage($data, $verify = false);

// Result structure
[
    'data' => string,          // Compressed data
    'cachedOffset' => int,     // Offset for cached chunks
    'cachedIndexes' => array,  // Cache indexes
    'cachedChunks' => array,   // Cached decompressed chunks
    'offsets' => array,        // Chunk offsets
    'sizes' => array,          // Chunk sizes
    'successes' => array       // Compression success flags (1 for success, 0 for failure)
]