GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - deminy/php-bsdiff: The bsdiff extension for PHP.

BranchesTags
Open more actions menu

Latest commit

 

History

76 Commits
76 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
tests
tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CLAUDE.md
CLAUDE.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
bsdiff.c
bsdiff.c
 
 
bsdiff.h
bsdiff.h
 
 
bspatch.c
bspatch.c
 
 
bspatch.h
bspatch.h
 
 
composer.json
composer.json
 
 
config.m4
config.m4
 
 
config.w32
config.w32
 
 
package.xml
package.xml
 
 
php_bsdiff.c
php_bsdiff.c
 
 
php_bsdiff.h
php_bsdiff.h
 
 
php_bsdiff.stub.php
php_bsdiff.stub.php
 
 
php_bsdiff_arginfo.h
php_bsdiff_arginfo.h
 
 

Repository files navigation

php-bsdiff

Build Status PHP version

bsdiff is a PHP extension to build and apply patches to binary files.

This PHP extension is based on the bsdiff and bspatch libraries maintained by Matthew Endsley. The original algorithm and implementation was developed by Colin Percival. The algorithm is detailed in Colin's paper, Naïve Differences of Executable Code. For more information, visit his website at http://www.daemonology.net/bsdiff/.


Requirements

  • PHP 7.2 to PHP 8.5
  • BZip2 1.0+
  • Linux, macOS, or Windows

Installation

Install via PECL

pecl install bsdiff

# or, if you want to install it without the prompts (i.e., using default installation option(s)):
yes '' | pecl install bsdiff

In case BZip2 can't be found automatically, use option with-bz2 to specify the installation directory of BZip2. e.g.,

pecl install -D 'with-bz2="/usr/local/opt/bzip2"' bsdiff # If BZip2 is installed via Homebrew on MacOS.

Install via PIE

composer require bsdiff/bsdiff

In case BZip2 can't be found automatically, pass the with-bz2 option:

composer require bsdiff/bsdiff -- --with-bz2=/usr/local/opt/bzip2

Manual Installation

phpize
./configure
make
make test
make install

Once done, add the following line to your php.ini file:

extension=bsdiff.so

In case BZip2 can't be found automatically, use option --with-bz2 to specify the installation directory of BZip2:

./configure --with-bz2=/path/to/bzip2 # If BZip2 is installed in a non-standard location.

# e.g., to configure with the BZip2 library provided by Xcode Command Line Tools on MacOS, use:
./configure --with-bz2=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr
# or, if BZip2 is installed via Homebrew on MacOS:
./configure --with-bz2=/usr/local/opt/bzip2

Usage

There are two PHP functions added by the extension:

/**
  * @throws \BsdiffException If there is any error happens.
  */
function bsdiff_diff(string $old_file, string $new_file, string $diff_file): void {}

/**
  * @throws \BsdiffException If there is any error happens.
  */
function bsdiff_patch(string $old_file, string $new_file, string $diff_file): void {}

Here is an example on how to use the extension:

<?php
$old_file  = '/path/to/the/old/file';
$new_file  = '/path/to/the/new/file';
$diff_file = '/path/to/the/diff/file';

// To create the diff file.
try {
    bsdiff_diff($old_file, $new_file, $diff_file);
} catch (BsdiffException $e) {
    // Handle the exception.
}

// To apply the diff file.
$patched_file = '/path/to/the/patched/file';
try {
    bsdiff_patch($old_file, $patched_file, $diff_file);
} catch (BsdiffException $e) {
    // Handle the exception.
}
// File $patched_file will have exactly the same content as file $new_file.

License

The extension is licensed under the Modified BSD License (BSD-3-Clause). The bundled bsdiff/bspatch libraries are licensed under the BSD-2-Clause license (included in the same LICENSE file).

About

The bsdiff extension for PHP.

pecl.php.net/bsdiff

Topics

bsdiffbspatchphpphp-extension

Resources

Readme
License
Activity

Stars

4 stars

Watchers

1 watching

Forks

3 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.