PHPackages                             kjdev/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. kjdev/lz4

ActivePhp-ext[Utility &amp; Helpers](/categories/utility)

kjdev/lz4
=========

A compression/decompression with LZ4

0.6.0(6mo ago)154465↓50%40[6 issues](https://github.com/kjdev/php-ext-lz4/issues)[1 PRs](https://github.com/kjdev/php-ext-lz4/pulls)MITCPHP &gt;= 5.6.0CI passing

Since Apr 11Pushed 6mo ago14 watchersCompare

[ Source](https://github.com/kjdev/php-ext-lz4)[ Packagist](https://packagist.org/packages/kjdev/lz4)[ RSS](/packages/kjdev-lz4/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

LZ4 Extension for PHP
=====================

[](#lz4-extension-for-php)

[![Linux](https://github.com/kjdev/php-ext-lz4/actions/workflows/linux.yaml/badge.svg?branch=master)](https://github.com/kjdev/php-ext-lz4/actions/workflows/linux.yaml)[![Windows](https://github.com/kjdev/php-ext-lz4/actions/workflows/windows.yaml/badge.svg?branch=master)](https://github.com/kjdev/php-ext-lz4/actions/workflows/windows.yaml)

This extension allows LZ4.

Documentation for LZ4 can be found at [» https://github.com/Cyan4973/lz4](https://github.com/Cyan4973/lz4).

Build from sources
------------------

[](#build-from-sources)

```
% git clone --recursive --depth=1 https://github.com/kjdev/php-ext-lz4.git
% cd php-ext-lz4
% phpize
% ./configure
% make
% make install

```

To use the system library

```
% ./configure --with-lz4-includedir=/usr
```

Distribution binary packages
----------------------------

[](#distribution-binary-packages)

### Fedora / CentOS / RHEL

[](#fedora--centos--rhel)

RPM packages of this extension are available in [» Remi's RPM repository](https://rpms.remirepo.net/) and are named **php-lz4**.

### Debian

[](#debian)

DEB packages of this extension are available in [» Ondřej Surý's DEB repository](https://deb.sury.org/) and are named **php-lz4**.

Installation via PIE
--------------------

[](#installation-via-pie)

```
pie install kjdev/lz4
```

Configuration
-------------

[](#configuration)

php.ini:

```
extension=lz4.so

```

Function
--------

[](#function)

- lz4\_compress — LZ4 compression (block format)
- lz4\_uncompress — LZ4 decompression (block format)
- lz4\_compress\_frame — LZ4 compression (frame format)
- lz4\_uncompress\_frame — LZ4 decompression (frame format)

### lz4\_compress — LZ4 compression

[](#lz4_compress--lz4-compression)

#### Description

[](#description)

string **lz4\_compress** ( string *$data* \[ , int *$level* = 0 , string *$extra* = NULL \] )

LZ4 compression.

#### Parameters

[](#parameters)

- *data*

    The string to compress.
- *level*

    The level of compression (1-12, Recommended values are between 4 and 9). (Default to 0, Not High Compression Mode.)
- *extra*

    Prefix to compressed data.

#### Return Values

[](#return-values)

Returns the compressed data or FALSE if an error occurred.

### lz4\_uncompress — LZ4 decompression

[](#lz4_uncompress--lz4-decompression)

#### Description

[](#description-1)

string **lz4\_uncompress** ( string *$data* \[ , long *$maxsize* = -1 , long *$offset* = -1 \] )

LZ4 decompression.

#### Parameters

[](#parameters-1)

- *data*

    The compressed string.
- *maxsize*

    Allocate size output data.
- *offset*

    Offset to decompressed data.

#### Return Values

[](#return-values-1)

Returns the decompressed data or FALSE if an error occurred.

### lz4\_compress\_frame — LZ4 compression (frame format)

[](#lz4_compress_frame--lz4-compression-frame-format)

#### Description

[](#description-2)

string **lz4\_compress\_frame** ( string *$data* \[ , int *$level* = 0 , int *$max\_block\_size* = 0 , int *$checksums* = 0 \] )

LZ4 compression to frame.

#### Parameters

[](#parameters-2)

- *data*

    The string to compress.
- *level*

    The level of compression (1-12, Recommended values are between 4 and 9). (Default to 0, Not High Compression Mode.)
- *max\_block\_size*

    Maximum uncompressed size of each block. Pass any of the following values:

    - *LZ4\_BLOCK\_SIZE\_64KB*
    - *LZ4\_BLOCK\_SIZE\_256KB*
    - *LZ4\_BLOCK\_SIZE\_1MB*
    - *LZ4\_BLOCK\_SIZE\_4MB*

    Any other value will be treated as *LZ4\_BLOCK\_SIZE\_64KB*.
- *checksums*

    Enable/disable frame-level and block-level checksums. Pass a bitwise combination of the following constants:

    - *LZ4\_CHECKSUM\_FRAME*: frame-level checksum
    - *LZ4\_CHECKSUM\_BLOCK*: block-level checksum

#### Return Values

[](#return-values-2)

Returns the compressed data or FALSE if an error occurred.

### lz4\_uncompress\_frame — LZ4 decompression (frame format)

[](#lz4_uncompress_frame--lz4-decompression-frame-format)

#### Description

[](#description-3)

string **lz4\_uncompress\_frame** ( string *$data* )

LZ4 decompression from frame.

#### Parameters

[](#parameters-3)

- *data*

    The compressed string.

#### Return Values

[](#return-values-3)

Returns the decompressed data or FALSE if an error occurred.

Examples
--------

[](#examples)

```
$data = lz4_compress('test');

lz4_uncompress($data);

```

Compress Data
-------------

[](#compress-data)

### Default

[](#default)

```
$data = lz4_compress('test')

```

[![compress-default](docs/compress-default.png)](docs/compress-default.png)

### Extra prefix data

[](#extra-prefix-data)

```
$data = lz4_compress('test', false, 'PREFIX')

```

[![compress-extra](docs/compress-extra.png)](docs/compress-extra.png)

Uncompress Data
---------------

[](#uncompress-data)

### Default

[](#default-1)

```
lz4_uncompress($data);

```

[![uncompress-default](docs/uncompress-default.png)](docs/uncompress-default.png)

### Offset

[](#offset)

```
lz4_uncompress($data, 256, 6);

```

[![uncompress-offset](docs/uncompress-offset.png)](docs/uncompress-offset.png)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance66

Regular maintenance activity

Popularity36

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 81% 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

Every ~105 days

Total

3

Last Release

193d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/18072f3d3a57cc6f8e11a0f405648caf4927261c0fc122f9cfa0d1441e087fb7?d=identicon)[kjdev](/maintainers/kjdev)

---

Top Contributors

[![kjdev](https://avatars.githubusercontent.com/u/465132?v=4)](https://github.com/kjdev "kjdev (94 commits)")[![cracksalad](https://avatars.githubusercontent.com/u/28577589?v=4)](https://github.com/cracksalad "cracksalad (9 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (8 commits)")[![sergey-dryabzhinsky](https://avatars.githubusercontent.com/u/717597?v=4)](https://github.com/sergey-dryabzhinsky "sergey-dryabzhinsky (2 commits)")[![Jan-E](https://avatars.githubusercontent.com/u/1757825?v=4)](https://github.com/Jan-E "Jan-E (1 commits)")[![KirbyDE](https://avatars.githubusercontent.com/u/24271469?v=4)](https://github.com/KirbyDE "KirbyDE (1 commits)")[![Xon](https://avatars.githubusercontent.com/u/635541?v=4)](https://github.com/Xon "Xon (1 commits)")

### Embed Badge

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

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

###  Alternatives

[imanilchaudhari/yii2-currency-converter

This extension will help to find out current currency conversion rate.

2011.6k](/packages/imanilchaudhari-yii2-currency-converter)

PHPackages © 2026

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