pavetheway91 / libdeflate
Compression with Libdeflate
Package info
github.com/pavetheway91/php-libdeflate
Language:C
Type:php-ext
Ext name:ext-libdeflate
pkg:composer/pavetheway91/libdeflate
Requires
- php: >= 7.3.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-08-23 16:11:18 UTC
README
Keeping the lights on after pmmp/ext-libdeflate was archived.
PHP bindings for libdeflate, a zlib replacement with significantly better performance.
Installation
Pie
With bundled libdeflate:
pie install pavetheway91/libdeflate
With system libdeflate:
pie install pavetheway91/libdeflate --with-system-libdeflate
Binary packages
Fedora / RHEL / Rocky packages available from Remi's RPM repository
Features
At the time of writing, only libdeflate's compression APIs are implemented.
Performance
Compared to zlib_encode(), a 40% performance improvement can be observed at level 1, rising to 50-70% at level 6 (default), for approximately the same compression ratios. Also, libdeflate_deflate_compress() was observed to sometimes be faster at level 6 compression than zlib_encode() at level 1 compression.
Compression levels
Libdeflate provides compression levels up to 12. At level 12, compression ratio is in the same league as zopfli, but libdeflate wins in speed.
API
<?php /** * Equivalent to zlib_encode($data, ZLIB_ENCODING_RAW, $level) * @throws \RuntimeException */ function libdeflate_deflate_compress(string $data, int $level = 6) : string; /** * Equivalent to zlib_encode($data, ZLIB_ENCODING_DEFLATE, $level) * @throws \RuntimeException */ function libdeflate_zlib_compress(string $data, int $level = 6) : string; /** * Equivalent to zlib_encode($data, ZLIB_ENCODING_GZIP, $level) * @throws \RuntimeException */ function libdeflate_gzip_compress(string $data, int $level = 6) : string;