This extension allows Brotli compression.
Documentation for Brotli can be found at » https://github.com/google/brotli/.
% git clone --recursive --depth=1 https://github.com/kjdev/php-ext-brotli.git % cd php-ext-brotli % phpize % ./configure % make $ make install To use the system library (using pkg-config)
% ./configure --with-libbrotliRPM packages of this extension are available in » Remi's RPM repository and are named php-brotli.
brotli.ini:
extension=brotli.so - brotli_compress — Compress a string
- brotli_uncompress — Uncompress a compressed string
string brotli_compress ( string $data [, int $quality = 11, int $mode = -1 ] )
This function compress the given string using the ZLIB data format.
-
data
The data to compress.
-
quality
The higher the quality, the slower the compression. (Defaults to 11)
-
mode
The compression mode can be
BROTLI_GENERIC(default),BROTLI_TEXT(for UTF-8 format text input) orBROTLI_FONT(for WOFF 2.0).
The compressed string or FALSE if an error occurred.
string brotli_uncompress ( string $data [, int $length = 0 ] )
This function uncompress a compressed string.
-
data
The data compressed by brotli_compress().
-
length
The maximum length of data to decode.
The original uncompressed data or FALSE on error.
$compressed = brotli_compress('Compresstest'); $uncompressed = brotli_uncompress($compressed); echo $uncompressed; 