Skip to content
PharaonicPublic

About

Semantic structured diffs and GitHub-style text diffs for PHP: Diff::between() reports added, removed, modified and moved values at their paths, with identity-aware lists and redaction; Diff::text() gives Myers line diffs, hunks, unified patches and HTML.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

PHP Version : 8.6 License Build
Source Packagist Version Packagist Downloads

Know exactly what changed in PHP data and text.


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

Guide

How to Compare Nested Arrays in PHP: Beyond array_diff()

Documentation

Full documentation: PHP Diff Documentation.

Support & Security

See SUPPORT.md and SECURITY.md.

License

MIT. See LICENSE.

About

Semantic structured diffs and GitHub-style text diffs for PHP: Diff::between() reports added, removed, modified and moved values at their paths, with identity-aware lists and redaction; Diff::text() gives Myers line diffs, hunks, unified patches and HTML.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages