Search by

pharaonic / php-diff

Pharaonic

Semantic structured diffs and GitHub-style text diffs for PHP: added, removed, modified and moved values with paths, identity-aware lists, redaction, hunks, unified patches and HTML.

8.3.0 2026-10-16 07:56 UTC

This package is auto-updated.

Last update: 2026-10-16 07:56:28 UTC


README

PHP Version : 8.3 License Tests
Source Packagist Version Packagist Downloads

Know exactly what changed in PHP data and text.

Added, removed, modified and moved values at their exact paths, records matched by ID, redacted secrets, and GitHub-style line diffs.

Installation

composer require pharaonic/php-diff

Usage

Compare two values

use Pharaonic\Diff\Diff;

$before = ['name' => 'Ali', 'age' => 30, 'phone' => '0100'];
$after  = ['name' => 'Ali', 'age' => 31, 'email' => 'ali@example.com'];

$result = Diff::between($before, $after);

$result->wasModified('age');   // true
$result->wasAdded('email');    // true
$result->wasRemoved('phone');  // true
$result->hasChanged('name');   // false

Compare two texts

echo Diff::text("apple\nbanana\ncherry\n", "apple\nblueberry\ncherry\n")->toUnified();
--- before
+++ after
@@ -1,3 +1,3 @@
 apple
-banana
+blueberry
 cherry

Documentation

Full documentation: PHP Diff Documentation.

Support & Security

See SUPPORT.md and SECURITY.md.

License

MIT. See LICENSE.