petrknap/xz-utils
最新稳定版本:v1.1.0
Composer 安装命令:
composer require petrknap/xz-utils
包简介
XZ Utils (wrapper)
README 文档
README
User-friendly wrapper for XZ Utils, providing simplified and streamlined access to powerful data compression and decompression tools. For ease of use, you can use the approach known from the compression extensions:
$encoded = xzencode(b'data') or throw new Exception(); $decoded = xzdecode($encoded) or throw new Exception(); printf('`%s` was decoded from encoded base64(`%s`)', $decoded, base64_encode($encoded));
Object-based approach
All functionality is available object-wise through the classes Lzma and Xz.
$xz = new PetrKnap\XzUtils\Xz(); $compressed = $xz->compress(b'data'); $decompressed = $xz->decompress($compressed); printf('`%s` was decompressed from compressed base64(`%s`)', $decompressed, base64_encode($compressed));
Filter-based approach
For more complex use cases, a filter-based approach is also possible.
use PetrKnap\ExternalFilter\Filter; use PetrKnap\XzUtils\FilterFactory; $file = fopen('README.md', 'r'); $xzFile = tmpfile(); # compress file to file FilterFactory::xz()->compress()->filter(input: $file, output: $xzFile); fclose($file); rewind($xzFile); # decompress file, filter headline and print it print FilterFactory::xz()->decompress()->pipe(new Filter('head', ['-n', '1']))->filter($xzFile); fclose($xzFile);
Run composer require petrknap/xz-utils to install it.
You can support this project via donation.
The project is licensed under the terms of the LGPL-3.0-or-later.
统计信息
- 总下载量: 62
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: LGPL-3.0-or-later
- 更新时间: 2024-11-03