This extension allows XZ (liblzma).
Documentation for XZ can be found at » https://tukaani.org/xz.
% git clone --depth=1 https://github.com/kjdev/php-ext-xz.git
% phpize
% ./configure
% make
% make install
You need to install xz-devel using dnf/yum (Fedora, RHEL, CentOS...), or liblzma-dev using apt-get or aptitude (Debian, Ubuntu...)
php.ini:
extension=xz.so
Name | Description |
---|---|
XZ_COMPRESS_LEVEL_MIN | Minimal compress level value |
XZ_COMPRESS_LEVEL_MAX | Maximal compress level value |
XZ_COMPRESS_LEVEL_DEFAULT | Default compress level value |
- xz_compress — XZ compression
- xz_uncompress — XZ decompression
string xz_compress ( string $data [, int $level = 6 ] )
XZ compression.
-
data
The string to compress.
-
level
The level of compression (0-9). (Defaults to 6)
Returns the compressed data or FALSE if an error occurred.
string xz_uncompress ( string $data )
XZ decompression.
Alias: xz_decompress
-
data
The compressed string.
Returns the decompressed data or FALSE if an error occurred.
Namespace Xz;
function compress( $data [, $level = 6 ] )
function uncompress( $data )
xz_compress
and xz_uncompress
function alias.
XZ compression and uncompression are available using the
compress.xz://
stream prefix.
// Using functions
$data = xz_compress('test');
xz_uncompress($data);
// Using namespaced functions
$data = \Xz\compress('test');
\Xz\uncompress($data);
// Using streams
file_put_contents('compress.xz:///patch/to/data.xz', $data);
readfile('compress.xz:///patch/to/data.xz');