caxy/php-htmldiff
Compare two HTML snippets/files and generate a marked-up diff highlighting insertions, deletions, and changes. Easy Composer install, simple API (HtmlDiff->build()), configurable behavior and CSS-friendly output; includes a live demo and Symfony bundle option.
Adopt if:
Look elsewhere if:
Symfony\Component\Diff\Diff or php-diff).<div>Hello</div> vs. <div>Hi</div>) and a regex-based solution suffices.html-diff, JavaScript: jsdiff).For Executives: "This package lets us automate visual regression testing for our web apps by comparing HTML snapshots between deployments—catching UI bugs before users do. For example, if a template update accidentally breaks a dashboard layout, we’ll see a highlighted diff in CI instead of a support ticket. It’s a low-code, high-impact way to reduce manual QA effort by 30%+ while improving product consistency. The Laravel integration means we can roll it out without heavy dev lift."
For Engineers: *"php-htmldiff is a battle-tested, PHP-native library for highlighting HTML differences with support for tables, lists, and nested structures. Key perks:
setMatchThreshold(95) for strict comparisons) and disable HTML purifier for edge cases.HtmlDiffBundle for Symfony.$diff = new HtmlDiff($oldHtml, $newHtml);
echo $diff->build(); // Renders <ins>added</ins> and <del>removed</del> tags.
```*
**Tradeoff**: GPL-2.0 license (fine for internal tools; check compliance for open-source projects)."*
How can I help you explore Laravel packages today?