This extension allows Zstandard.
Documentation for Zstandard can be found at » https://github.com/facebook/zstd.
% git clone --recursive --depth=1 https://github.com/kjdev/php-ext-zstd.git
% phpize
% ./configure
% make
% make install
To use the system library
% ./configure --with-libzstd
Fedora users can install the » php-zstd package from official repository.
dnf install php-zstd
CentOS / RHEL (and other clones) users can install the » php-zstd package from » EPEL repository.
yum install php-zstd
Other RPM packages of this extension, for other PHP versions, are available in » Remi's RPM repository.
zstd.ini:
extension=zstd.so
Name | Description |
---|---|
ZSTD_COMPRESS_LEVEL_MIN | Minimal compress level value |
ZSTD_COMPRESS_LEVEL_MAX | Maximal compress level value |
ZSTD_COMPRESS_LEVEL_DEFAULT | Default compress level value |
LIBZSTD_VERSION_NUMBER | libzstd version number |
LIBZSTD_VERSION_STRING | libzstd version string |
- zstd_compress — Zstandard compression
- zstd_uncompress — Zstandard decompression
- zstd_compress_dict — Zstandard compression using a digested dictionary
- zstd_uncompress_dict — Zstandard decompression using a digested dictionary
string zstd_compress ( string $data [, int $level = 3 ] )
Zstandard compression.
-
data
The string to compress.
-
level
The level of compression (1-22). (Defaults to 3, 0 for no compression)
A value smaller than 0 means a faster compression level. (Zstandard library 1.3.4 or later)
Returns the compressed data or FALSE if an error occurred.
string zstd_uncompress ( string $data )
Zstandard decompression.
Alias: zstd_decompress
-
data
The compressed string.
Returns the decompressed data or FALSE if an error occurred.
string zstd_compress_dict ( string $data , string $dict )
Zstandard compression using a digested dictionary.
Alias: zstd_compress_usingcdict
-
data
The string to compress.
-
dict
The Dictionary data.
Returns the compressed data or FALSE if an error occurred.
string zstd_uncompress_dict ( string $data , string $dict )
Zstandard decompression using a digested dictionary.
Alias: zstd_dempress_dict, zstd_unmpress_usingcdict, zstd_decompress_usingcdict
-
data
The compressed string.
-
dict
The Dictionary data.
Returns the decompressed data or FALSE if an error occurred.
Namespace Zstd;
function compress( $data [, $level = 3 ] )
function uncompress( $data )
function compress_dict ( $data, $dict )
function uncompress_dict ( $data, $dict )
zstd_compress
, zstd_uncompress
, zstd_compress_dict
and
zstd_uncompress_dict
function alias.
Zstd compression and uncompression are available using the
compress.zstd://
stream prefix.
// Using functions
$data = zstd_compress('test');
zstd_uncompress($data);
// Using namespaced functions
$data = \Zstd\compress('test');
\Zstd\uncompress($data);
// Using streams
file_put_contents("compress.zstd:///patch/to/data.zstd", $data);
readfile("compress.zstd:///patch/to/data.zstd");