PHPackages                             syntaxx/lz4 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. syntaxx/lz4

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

syntaxx/lz4
===========

A pure PHP implementation of LZ4 compression and decompression

v0.1.0(1y ago)0921MITPHPPHP &gt;=8.1

Since May 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Syntaxx-HQ/PHPX-Lz4)[ Packagist](https://packagist.org/packages/syntaxx/lz4)[ RSS](/packages/syntaxx-lz4/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (2)Used By (1)

PHPX-LZ4
========

[](#phpx-lz4)

A quick and dirty AI port of [MiniLZ4](https://github.com/emscripten-core/emscripten/blob/main/third_party/mini-lz4.js) to PHP. MiniLZ4 is a minimal implementation of LZ4 block encoding and decoding, originally based on [node-lz4](https://github.com/pierrec/node-lz4).

Overview
--------

[](#overview)

This library provides a pure PHP implementation of the LZ4 compression algorithm, specifically ported from the JavaScript MiniLZ4 implementation. It maintains compatibility with the original implementation while providing a PHP-native interface.

Features
--------

[](#features)

- Pure PHP implementation
- A quick and dirty AI port of MiniLZ4's
- Block compression and decompression
- Package compression with chunking support
- Verification capabilities
- No external dependencies

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require syntaxx/lz4
```

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1

Usage
-----

[](#usage)

### Basic Compression/Decompression

[](#basic-compressiondecompression)

```
use Syntaxx\LZ4\LZ4;

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

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

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

### Package Compression

[](#package-compression)

```
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)
]
```

Development
-----------

[](#development)

### Running Tests

[](#running-tests)

```
# Run tests
composer test

# Run tests with coverage
composer test:coverage
```

### Code Style

[](#code-style)

```
# Check code style
composer cs

# Fix code style issues
composer cs:fix
```

License
-------

[](#license)

This project is licensed under the MIT License, following the same license as the original MiniLZ4 implementation.

Credits
-------

[](#credits)

- Original MiniLZ4 implementation by the Emscripten team
- Based on node-lz4 by Pierre Curto

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance46

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

413d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1073586?v=4)[Øystein Kambo Tangerås](/maintainers/kambo)[@kambo](https://github.com/kambo)

---

Top Contributors

[![kambo-1st](https://avatars.githubusercontent.com/u/6493048?v=4)](https://github.com/kambo-1st "kambo-1st (1 commits)")

---

Tags

compressiondecompressionlz4

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/syntaxx-lz4/health.svg)

```
[![Health](https://phpackages.com/badges/syntaxx-lz4/health.svg)](https://phpackages.com/packages/syntaxx-lz4)
```

###  Alternatives

[kriswallsmith/assetic

Asset Management for PHP

3.8k49.3M161](/packages/kriswallsmith-assetic)[alchemy/zippy

Zippy, the archive manager companion

47723.4M53](/packages/alchemy-zippy)[composer/metadata-minifier

Small utility library that handles metadata minification and expansion.

181123.3M25](/packages/composer-metadata-minifier)[voku/html-min

HTML Compressor and Minifier

1885.0M64](/packages/voku-html-min)[assetic/framework

Asset Management for PHP

1011.5M23](/packages/assetic-framework)[emcconville/polyline-encoder

PHP Traits algorithms for Encoded Polyline &amp; Bing Point Compression

30334.4k1](/packages/emcconville-polyline-encoder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
