kjdev/lz4
Composer 安装命令:
pie install kjdev/lz4
包简介
A compression/decompression with LZ4
README 文档
README
This extension allows LZ4.
Documentation for LZ4 can be found at » https://github.com/Cyan4973/lz4.
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
Fedora / CentOS / RHEL
RPM packages of this extension are available in » Remi's RPM repository and are named php-lz4.
Debian
DEB packages of this extension are available in » Ondřej Surý's DEB repository and are named php-lz4.
Installation via PIE
pie install kjdev/lz4
Configuration
php.ini:
extension=lz4.so
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
Description
string lz4_compress ( string $data [ , int $level = 0 , string $extra = NULL ] )
LZ4 compression.
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
Returns the compressed data or FALSE if an error occurred.
lz4_uncompress — LZ4 decompression
Description
string lz4_uncompress ( string $data [ , long $maxsize = -1 , long $offset = -1 ] )
LZ4 decompression.
Parameters
-
data
The compressed string.
-
maxsize
Allocate size output data.
-
offset
Offset to decompressed data.
Return Values
Returns the decompressed data or FALSE if an error occurred.
lz4_compress_frame — LZ4 compression (frame format)
Description
string lz4_compress_frame ( string $data [ , int $level = 0 , int $max_block_size = 0 , int $checksums = 0 ] )
LZ4 compression to frame.
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.)
-
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
Returns the compressed data or FALSE if an error occurred.
lz4_uncompress_frame — LZ4 decompression (frame format)
Description
string lz4_uncompress_frame ( string $data )
LZ4 decompression from frame.
Parameters
-
data
The compressed string.
Return Values
Returns the decompressed data or FALSE if an error occurred.
Examples
$data = lz4_compress('test');
lz4_uncompress($data);
Compress Data
Default
$data = lz4_compress('test')
Extra prefix data
$data = lz4_compress('test', false, 'PREFIX')
Uncompress Data
Default
lz4_uncompress($data);
Offset
lz4_uncompress($data, 256, 6);
kjdev/lz4 适用场景与选型建议
kjdev/lz4 是一款 基于 C 开发的 Composer 扩展包,目前已累计 1.34k 次下载、GitHub Stars 达 156, 最近一次更新时间为 2025 年 04 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 kjdev/lz4 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kjdev/lz4 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 156
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-11



