Weave Code
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
Php Htmldiff

Php Htmldiff Laravel Package

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.

View on GitHub
Deep Wiki
Context7

A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.

Frequently asked questions about Php Htmldiff
How do I install php-htmldiff in a Laravel project?
Run `composer require caxy/php-htmldiff` to install via Composer. No additional Laravel-specific setup is required for basic usage, though you can register it as a singleton in a service provider for reusable configuration.
Can I use this package to compare HTML emails or dynamic content in Laravel?
Yes, php-htmldiff works well for comparing HTML emails or dynamic content. For large diffs (e.g., emails), wrap the diff generation in a Laravel queue job to avoid timeouts and use caching for repeated comparisons.
Does php-htmldiff support Laravel Blade templates or testing frameworks like Pest?
It integrates seamlessly with Blade via custom helpers or direct usage in controllers. For Pest, you can create a custom assertion like `assertHtmlDiff()` to compare HTML output with visual diffs in tests.
What Laravel versions are compatible with this package?
The package supports PHP 7.3+ and is fully compatible with Laravel 8, 9, and 10. For older Laravel versions (7.x), ensure PHP 7.3+ is used, as the package relies on modern PHP features.
How do I customize the CSS styling for diff output in Laravel?
Include the default CSS from the package demo or create your own. Use Laravel’s asset pipeline (e.g., Vite or Mix) to compile a custom CSS file for the diff output, or inline it directly in your Blade templates.
Is there a way to cache diff results for performance?
Yes, use Laravel’s cache system or the optional `doctrine/cache` dependency. Configure caching in the `HtmlDiffConfig` object or wrap diff generation in `cache()->remember()` for repeated comparisons.
Can I store diffs in a database or filesystem for later use?
Diffs can be stored in a `longtext` database column or saved to the filesystem (e.g., `storage/app/diffs/`). For large diffs, consider compressing them with `gzencode()` before storage.
What are the alternatives to php-htmldiff for HTML diffing in Laravel?
Alternatives include `str_diff()` for simple string-based diffs (less accurate for HTML) or DOM-based tools like `DOMDocument` (heavier). php-htmldiff is optimized for visual HTML diffs with minimal overhead.
How do I handle malformed HTML or edge cases like Unicode text?
Pre-process input with `htmlspecialchars_decode()` for malformed HTML. The package handles Unicode and RTL text (e.g., Arabic) natively. For self-closing tags like `<img/>`, ensure they’re properly formatted in the input.
Is there a Symfony bundle available, and can it be used in Laravel?
Yes, the `caxy/htmldiff-bundle` provides Symfony integration (e.g., Twig extensions). While it’s Symfony-focused, you can adapt its configuration logic for Laravel by manually binding the service in a Laravel service provider.
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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle