pharaonic / php-diff
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
Requires
- php: >=8.3 <8.4
Requires (Dev)
- laravel/pint: ^1.20
- pestphp/pest: ^4.0
- phpstan/phpstan: ^2.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
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.
