https://github.com/deminy/php-bsdiff
The bsdiff extension for PHP.
https://github.com/deminy/php-bsdiff
bsdiff bspatch php php-extension
Last synced: about 1 month ago
JSON representation
The bsdiff extension for PHP.
- Host: GitHub
- URL: https://github.com/deminy/php-bsdiff
- Owner: deminy
- License: other
- Created: 2022-08-24T05:56:48.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-27T20:11:27.000Z (5 months ago)
- Last Synced: 2025-03-25T01:44:09.934Z (about 2 months ago)
- Topics: bsdiff, bspatch, php, php-extension
- Language: C
- Homepage: https://pecl.php.net/bsdiff
- Size: 72.3 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# php-bsdiff
[](https://github.com/deminy/php-bsdiff/actions/workflows/ci.yml)
[](https://github.com/deminy/php-bsdiff)`bsdiff` is a PHP extension to build and apply patches to binary files.
This PHP extension is based on [the bsdiff and bspatch libraries][1] 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][1].
For more information, visit his website at .---
## Requirements
* PHP 7.2 to PHP 8.x
* BZip2 1.0+
* Linux, macOS, or Windows## Installation
## Install via PECL
```bash
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.,
```bash
pecl install -D 'with-bz2="/usr/local/opt/bzip2"' bsdiff # If BZip2 is installed via Homebrew on MacOS.
```## Manual Installation
```bash
phpize
./configure
make
make test
make install
```Once done, add the following line to your `php.ini` file:
```ini
extension=bsdiff.so
```In case BZip2 can't be found automatically, use option `--with-bz2` to specify the installation directory of BZip2. e.g.,
```bash
./configure --with-bz2=/usr/local/opt/bzip2 # If BZip2 is installed via Homebrew on MacOS.
```## Usage
There are two PHP functions added by the extension:
```php
/**
* @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