定制 codemasher/php-ext-xz 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

codemasher/php-ext-xz

最新稳定版本:1.1.4

Composer 安装命令:

pie install codemasher/php-ext-xz

包简介

A PHP Extension providing xz (LZMA2) compression/decompression via PHP streams.

README 文档

README

PHP Extension providing XZ (LZMA2) compression/decompression functions.
(see Implement lzma (xz?) compression)

Linux build Windows PHP8 build

Build & Installation

Linux

This module requires liblzma-dev (https://tukaani.org/xz/) as well as php7-dev or php8-dev. If you are using Ubuntu, you can easily install all of them by typing the following command in your terminal:

sudo apt-get install git php7.4-dev liblzma-dev

To build and install as module, perform the following steps:

git clone https://github.com/codemasher/php-ext-xz.git
cd php-ext-xz
phpize
./configure
make
sudo make install

Do not forget to add extension=xz.so to your php.ini.

Windows

Windows builds are now done automatically on each push; you can download them from the build artifacts or releases (after 1.1.2).

If you want to build it on your own, follow the steps under "Build your own PHP on Windows" to setup your build environment. Before the compilation step, clone this repository to [...]\php-src\ext\xz and proceed.

git clone https://github.com/Microsoft/php-sdk-binary-tools.git c:\php-sdk
cd c:\php-sdk
phpsdk-vs16-x64.bat

Run the buildtree script and check out the php source:

phpsdk_buildtree php-8.0
git clone https://github.com/php/php-src.git
cd php-src
git checkout PHP-8.0

Clone the xz extension and run the build:

git clone https://github.com/codemasher/php-ext-xz .\ext\xz
phpsdk_deps -u
buildconf --force
configure --enable-xz
nmake snap

Please note that the liblzma dependency is not included with PHP < 8, so you will need to download it manually and extract it into the deps directory.

Copy the php_xz.dll into the /ext directory of your PHP installation and add the line extension=xz to your php.ini or in case of the versioned .dll from the artifacts something like: extension=xz-0eebbf2-8.2-ts-vs16-x64 - omit the php_ and .dll.

Basic usage

$fh = xzopen('/tmp/test.xz', 'w');
xzwrite($fh, 'Data you would like compressed and written.');
xzclose($fh);

$fh = xzopen('/tmp/test.xz', 'r');
xzpassthru($fh);
xzclose($fh);
$str = 'Data you would like compressed.';

$encoded = xzencode($str);
$decoded = xzdecode($encoded);

Disclaimer

May or may not contain bugs. Use at your own risk.

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 1
  • Forks: 40
  • 开发语言: C

其他信息

  • 授权协议: PHP-3.01
  • 更新时间: 2025-09-12