https://github.com/kjdev/php-ext-xz
XZ Extension for PHP
https://github.com/kjdev/php-ext-xz
Last synced: 10 months ago
JSON representation
XZ Extension for PHP
- Host: GitHub
- URL: https://github.com/kjdev/php-ext-xz
- Owner: kjdev
- License: mit
- Created: 2019-09-30T00:05:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-03T03:28:21.000Z (over 5 years ago)
- Last Synced: 2025-02-09T06:44:16.145Z (about 1 year ago)
- Language: PHP
- Size: 25.4 KB
- Stars: 2
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# XZ Extension for PHP
[](https://travis-ci.org/kjdev/php-ext-xz)
This extension allows XZ (liblzma).
Documentation for XZ can be found at [» https://tukaani.org/xz](https://tukaani.org/xz/).
## Build from sources
``` bash
% 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...)
## Configration
php.ini:
```
extension=xz.so
```
## Constant
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
## Function
* xz\_compress — XZ compression
* xz\_uncompress — XZ decompression
### xz\_compress — XZ compression
#### Description
string **xz\_compress** ( string _$data_ [, int _$level_ = 6 ] )
XZ compression.
#### Pameters
* _data_
The string to compress.
* _level_
The level of compression (0-9).
(Defaults to 6)
#### Return Values
Returns the compressed data or FALSE if an error occurred.
### xz\_uncompress — XZ decompression
#### Description
string **xz\_uncompress** ( string _$data_ )
XZ decompression.
> Alias: xz\_decompress
#### Pameters
* _data_
The compressed string.
#### Return Values
Returns the decompressed data or FALSE if an error occurred.
## Namespace
```
Namespace Xz;
function compress( $data [, $level = 6 ] )
function uncompress( $data )
```
`xz_compress` and `xz_uncompress` function alias.
## Streams
XZ compression and uncompression are available using the
`compress.xz://` stream prefix.
## Examples
```php
// 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');
```