jfcherng/php-sequence-matcher
PHP longest sequence matcher inspired by Python difflib. Compare arrays or strings to find matching blocks and measure similarity, useful for diffing and change detection. Lightweight, modern PHP (8.4+) package.
Architecture fit
Integration feasibility
composer require. No Laravel service provider or facade needed.Technical risk
Key questions
Options class serialize correctly in Laravel’s cache/queue systems? Are there conflicts with Laravel’s attribute system?Stack fit
Migration path
php -v and composer validate.composer require jfcherng/php-sequence-matcher
namespace App\Services;
use jfcherng\SequenceMatcher\SequenceMatcher;
use jfcherng\SequenceMatcher\Options;
class SequenceMatcherService
{
public function __construct(
private readonly Options $options = new Options()
) {}
public function compare(array $oldSequence, array $newSequence): array
{
$matcher = new SequenceMatcher($oldSequence, $newSequence, $this->options);
return $matcher->getOpCodes();
}
}
// app/Providers/AppServiceProvider.php
public function register(): void
{
$this->app->singleton(SequenceMatcherService::class);
}
use App\Services\SequenceMatcherService;
class ConfigDiffController
{
public function __construct(
private readonly SequenceMatcherService $matcher
) {}
public function showDiff(array $oldConfig, array $newConfig)
{
$diffs = $this->matcher->compare($oldConfig, $newConfig);
// Render diffs...
}
}
// Old (pre-v5.0)
$matcher = new SequenceMatcher($a, $b, ['checkfinal' => true]);
// New (v5.0+)
$options = new Options(checkfinal: true);
$matcher = new SequenceMatcher($a, $b, $options);
Compatibility
Sequencing
getOpCodes()).Options::setCheckfinal(true)).Maintenance
Support
Scaling
laravel-debugbar and Xdebug.Failure modes
Options.Options not serializable in Laravel’s cache/queue.How can I help you explore Laravel packages today?