Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ATTENTION! Don't use this package and any forks, use sebastian/diff instead #53

gugglegum opened this Issue Aug 9, 2018 · 4 comments


None yet
3 participants
Copy link

gugglegum commented Aug 9, 2018

This package (chrisboulton/php-diff) is abandoned and not supported for several years. There's 167 other packages that forked from this root repo, but they are ugly. Most of them doesn't contain any changes. Many other contain questionable changes. A small number of forks contains 1-2 fixes or addition of some functionality necessary to authors. But all these forks are very low quality. Most of forks (as of original repo) doesn't use namespaces which makes difficulties if you want to use Composer's autoloader. There is a few repos that adds namespaces, but they seems to be abandoned too. They mostly are missing "Issues" section, so nobody can report a bug. Code quality is not good enough (at least for me). No unit-tests, no docs, no UTF-8 support. And all forks are crashes with count(): Parameter must be an array or an object that implements Countable when you making a diff for two arrays where one of them is empty. The error is in lib/Diff/SequenceMatcher.php in setSeq1() and setSeq2() (need replace if($a == $this->a) { to if($a === $this->a) {). This is very simple bug, but nobody found it and fixed.

I've tried these packages:

  1. chrisboulton/php-diff -- no namespaces, no multi-byte encodings
  2. phpspec/php-diff -- fixed some bugs, possible added multi-byte encodings, but still not namespaces, no Issues section
  3. adaptivemedia/php-text-difference -- added namespaces, but no Issues section, no Composer package, dev-stability
  4. JBlond/php-diff -- looks like supported, has Issues section, but no namespaces...

Then I found a better alternative of all this misunderstanding -- it's sebastian/diff ( It works little different, but it has much better code quality, actively maintaining, supported and the author is an authority in PHP world (he maintain PHPUnit). Actually previously it was a part of PHPUnit but then was factored out. So I recommend to use his package instead and forget about chrisboulton/php-diff and all its forks.


This comment has been minimized.

Copy link

JBlond commented Dec 7, 2018

@gugglegum PRs are welcomed 👍 and yes I work on it as needed.


This comment has been minimized.

Copy link

JBlond commented Jan 14, 2019

@gugglegum JBlond/php-diff has now namespaces


This comment has been minimized.

Copy link

jfcherng commented Jan 17, 2019

I have my changes.

  • Various bug fixes and performance rewrites.
  • Install with Composer. (jfcherng/php-diff)
  • UTF-8-ready.
  • Follow PSR-1, PSR-2, PSR-4.
  • Utilize PHP 7.1 features and make it type-hinted.
  • Add Json template.
  • Add char-level and word-level diff for HTML templates.
  • Add classes DiffHelper and RendererFactory for simpler usage.
  • Add multi-language support (English, Chinese, etc...) for templates.

This comment has been minimized.

Copy link

jfcherng commented Feb 19, 2019

@JBlond I see you still develop php-diff recently. Maybe you would be interested in my repo above too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.