pecl/xdiff 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

pecl/xdiff

最新稳定版本:2.2.0

Composer 安装命令:

pie install pecl/xdiff

包简介

File differences/patches.

README 文档

README

PHP extension for creating and applying patches to both text and binary files. Wraps the libxdiff library.

Installation

PIE (recommended)

pie install pecl/xdiff

PECL

pecl install xdiff

From source

Requires libxdiff with xdl_set_allocator, xdl_rabdiff, and XDL_PATCH_IGNOREBSPACE support.

phpize
./configure --with-xdiff
make
make install

API

Diff

xdiff_string_diff(string $str1, string $str2, int $context = 3, bool $minimal = false): string|false

Creates a unified diff of two strings. $context sets the number of surrounding lines. $minimal reduces diff size at the cost of speed.

xdiff_file_diff(string $file1, string $file2, string $dest, int $context = 3, bool $minimal = false): bool

Creates a unified diff of two files and writes the result to $dest.

xdiff_string_diff_binary(string $str1, string $str2): string|false

Creates a binary diff of two strings.

xdiff_file_diff_binary(string $file1, string $file2, string $dest): bool

Creates a binary diff of two files and writes the result to $dest.

xdiff_string_rabdiff(string $str1, string $str2): string|false

Creates a binary diff of two strings using the Rabin fingerprint algorithm.

xdiff_file_rabdiff(string $file1, string $file2, string $dest): bool

Creates a binary diff of two files using the Rabin fingerprint algorithm and writes the result to $dest.

Patch

xdiff_string_patch(string $file, string $patch, int $flags = XDIFF_PATCH_NORMAL, ?string &$error = null): string|bool

Applies a unified patch to a string. Returns the patched string, or false on error. Rejected chunks are returned via $error.

$flags: XDIFF_PATCH_NORMAL (default) or XDIFF_PATCH_REVERSE.

xdiff_file_patch(string $file, string $patch, string $dest, int $flags = XDIFF_PATCH_NORMAL): string|bool

Applies a unified patch from a file. Returns true on success, a string of rejected chunks on partial failure, or false on error.

xdiff_string_patch_binary(string $str, string $patch): string|false

Applies a binary patch to a string. Works with both bdiff and rabdiff patches.

xdiff_file_patch_binary(string $file, string $patch, string $dest): bool

Applies a binary patch from a file and writes the result to $dest.

Merge

xdiff_string_merge3(string $str1, string $str2, string $str3, ?string &$error = null): string|bool

Three-way merge of strings. Returns the merged string, or false on error. Conflicts are returned via $error.

xdiff_file_merge3(string $file1, string $file2, string $file3, string $dest): string|bool

Three-way merge of files. Returns true on success, a string of rejected chunks on conflict, or false on error.

Binary diff size

xdiff_string_bdiff_size(string $patch): int|false

Returns the size of the file that would be created by applying the given binary patch.

xdiff_file_bdiff_size(string $patch_file): int|false

Same as above, but reads the patch from a file.

Constants

Constant Description
XDIFF_PATCH_NORMAL Apply patch normally (default)
XDIFF_PATCH_REVERSE Reverse the patch
XDIFF_PATCH_IGNORESPACE Ignore whitespace when patching

统计信息

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

GitHub 信息

  • Stars: 16
  • Watchers: 7
  • Forks: 16
  • 开发语言: C

其他信息

  • 授权协议: PHP-3.01
  • 更新时间: 2026-04-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固