Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Htmldiff Laravel Package

ssddanbrown/htmldiff

A PHP library for generating a visual diff between two HTML strings. It compares content word by word while preserving HTML structure, outputting marked-up HTML with inserted and deleted content highlighted, useful for showing edits to rich-text content.

Deep Wiki
Context7

ssddanbrown/htmldiff is a PHP package for generating HTML-aware diffs between two HTML strings. It compares document content rather than raw text, making it useful for revision histories, CMS previews, and change-tracking interfaces where markup must remain renderable.

  • Structure-aware comparison for HTML content.
  • Outputs a browser-friendly HTML diff.
  • Simple API for comparing two HTML strings.
  • Composer-installable with PSR-4 autoloading.
  • Suitable for content revision and change-preview workflows.
Frequently asked questions about Htmldiff
How do I install ssddanbrown/htmldiff in a Laravel app?
Install it with Composer using composer require ssddanbrown/htmldiff. Laravel's Composer autoloading will make the library available without any framework registration. Because the upstream GitHub repository is archived and migrated to Codeberg, confirm that the Packagist package still resolves and pin a known-good version.
Does ssddanbrown/htmldiff support Laravel 10 or Laravel 11?
The library is framework-agnostic and has no Laravel-specific version constraints, so compatibility depends mainly on your PHP version. It does not ship a service provider, facade, or config file, so Laravel 10 and 11 can use it as a plain Composer dependency. Test it against your target PHP version because archived upstream code may not receive future compatibility patches.
Is there a service provider or config file for htmldiff in Laravel?
No. ssddanbrown/htmldiff is a plain PHP library with no Laravel integration layer, service provider, facade, or configuration file. If you want container injection, create a thin wrapper class and bind it in your own AppServiceProvider. That wrapper also gives you a stable interface if you later swap the diff engine.
How do I generate an HTML diff between two document versions in Laravel?
Instantiate the library's diff object, pass the old and new HTML strings, and render the returned display-ready HTML in your Blade view. The output marks inserted and removed content so users can review document changes. Keep the integration behind a small service class so controllers and jobs do not depend directly on the library.
Can I safely render htmldiff output in a Blade view?
Treat the diff output as untrusted markup, especially if either input side contains user-authored HTML. Apply a sanitization step before rendering and decide clearly whether raw input HTML is allowed. The library returns rendered HTML by design, so escaping or purifying the result is an application responsibility.
What is ssddanbrown/htmldiff best used for?
It is best suited to document revision comparisons such as CMS content, prose, audit views, and version previews where readable HTML output matters. It compares markup while preserving structure and highlights inserted and removed content. It is less ideal when you need a structured diff data model or fine-grained control over attribute and CSS changes.
How does ssddanbrown/htmldiff handle large or malformed HTML documents?
There are no published guarantees for large or deeply nested documents, so benchmark time and memory against your largest realistic inputs. Malformed or unbalanced HTML is common with user-edited content and may produce unpredictable results. Run representative document pairs through the library before committing to it in production.
What are the alternatives to ssddanbrown/htmldiff for PHP?
caxy/php-htmldiff is a commonly mentioned alternative, and a bake-off against your real documents is the best way to compare them. Evaluate output readability, handling of attributes and inline styles, malformed HTML behavior, and maintenance activity. Keep the diff engine behind an interface so switching alternatives does not affect call sites.
Is ssddanbrown/htmldiff still maintained?
The GitHub repository is archived and explicitly migrated to Codeberg, so ongoing maintenance depends on the Codeberg project. Community adoption is very low and the library has a single-maintainer risk profile. If you adopt it, consider pinning a commit or maintaining a private fork under the MIT license.
How should I test HTML diff output in a Laravel application?
Test with several real document pairs from your own data, including the largest, messiest, and most attribute-heavy examples. Assert that insertions and deletions appear as expected, verify your sanitization step, and add performance checks for realistic document sizes. Also test malformed or unbalanced HTML because user-edited content often produces it.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console