Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjdev/php-ext-lz4
LZ4 Extension for PHP
https://github.com/kjdev/php-ext-lz4
Last synced: 4 days ago
JSON representation
LZ4 Extension for PHP
- Host: GitHub
- URL: https://github.com/kjdev/php-ext-lz4
- Owner: kjdev
- License: mit
- Created: 2012-08-27T03:59:42.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2024-11-25T21:37:37.000Z (about 2 months ago)
- Last Synced: 2024-12-30T23:14:33.821Z (11 days ago)
- Language: PHP
- Size: 283 KB
- Stars: 151
- Watchers: 19
- Forks: 38
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LZ4 Extension for PHP
[![Linux](https://github.com/kjdev/php-ext-lz4/workflows/Linux/badge.svg?branch=master)](https://github.com/kjdev/php-ext-lz4/actions?query=workflow%3ALinux+branch%3Amaster)
[![Windows](https://github.com/kjdev/php-ext-lz4/workflows/Windows/badge.svg?branch=master)](https://github.com/kjdev/php-ext-lz4/actions?query=workflow%3AWindows+branch%3Amaster)This extension allows LZ4.
Documentation for LZ4 can be found at
[» https://github.com/Cyan4973/lz4](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 installTo use the system library
``` bash
% ./configure --with-lz4-includedir=/usr
```## Distribution binary packages
### 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
DEB packages of this extension are available in [» Ondřej Surý's DEB repository](https://deb.sury.org/) and are named **php-lz4**.
## Configuration
php.ini:
extension=lz4.so
## Function
* lz4\_compress — LZ4 compression
* lz4\_uncompress — LZ4 decompression### lz4\_compress — LZ4 compression
#### Description
string **lz4\_compress** ( string _$data_ [ , int _$level_ = 0 , string _$extra_ = NULL ] )
LZ4 compression.
#### Pameters
* _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.
#### Pameters
* _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.
## Examples
$data = lz4_compress('test');
lz4_uncompress($data);
## Compress Data
### Default
$data = lz4_compress('test')
![compress-default](docs/compress-default.png)
### Extra prefix data
$data = lz4_compress('test', false, 'PREFIX')
![compress-extra](docs/compress-extra.png)
## Uncompress Data
### Default
lz4_uncompress($data);
![uncompress-default](docs/uncompress-default.png)
### Offset
lz4_uncompress($data, 256, 6);
![uncompress-offset](docs/uncompress-offset.png)