Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 76 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ RPM packages of this extension are available in [» Remi's RPM repository](https

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

```bash
pie install kjdev/lz4
```


## Configuration

Expand All @@ -42,8 +48,10 @@ php.ini:

## Function

* lz4\_compress — LZ4 compression
* lz4\_uncompress — LZ4 decompression
* 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

Expand All @@ -53,7 +61,7 @@ string **lz4\_compress** ( string _$data_ [ , int _$level_ = 0 , string _$extra_

LZ4 compression.

#### Pameters
#### Parameters

* _data_

Expand Down Expand Up @@ -81,7 +89,7 @@ string **lz4\_uncompress** ( string _$data_ [ , long _$maxsize_ = -1 , long _$of

LZ4 decompression.

#### Pameters
#### Parameters

* _data_

Expand All @@ -99,6 +107,70 @@ LZ4 decompression.

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');
Expand Down
2 changes: 1 addition & 1 deletion config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if test "$PHP_LZ4" != "no"; then
else
AC_MSG_RESULT(use bundled version)

PHP_NEW_EXTENSION(lz4, lz4.c lz4/lib/lz4.c lz4/lib/lz4hc.c lz4/lib/xxhash.c, $ext_shared)
PHP_NEW_EXTENSION(lz4, lz4.c lz4/lib/lz4.c lz4/lib/lz4hc.c lz4/lib/lz4frame.c lz4/lib/xxhash.c, $ext_shared)

PHP_ADD_BUILD_DIR($ext_builddir/lz4/lib, 1)
PHP_ADD_INCLUDE([$ext_srcdir/lz4/lib])
Expand Down
2 changes: 1 addition & 1 deletion config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (PHP_LZ4 != "no") {
EXTENSION("lz4", "lz4.c", PHP_LZ4_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
} else {
EXTENSION("lz4", "lz4.c", PHP_LZ4_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
ADD_SOURCES("lz4/lib", "lz4.c lz4hc.c xxhash.c", "lz4", "lz4\\lib");
ADD_SOURCES("lz4/lib", "lz4.c lz4frame.c lz4hc.c xxhash.c", "lz4", "lz4\\lib");
ADD_FLAG("CFLAGS_LZ4", " /I" + configure_module_dirname + " /I" + configure_module_dirname + "/lz4/lib");
}
PHP_INSTALL_HEADERS("ext/lz4/", "php_lz4.h");
Expand Down
Loading