jrk/levenshtein-bundle
jrk/levenshtein-bundle offers Levenshtein distance utilities for PHP, useful for comparing strings, fuzzy matching, spelling suggestions, and similarity checks. A lightweight, low-adoption package; review suitability before production use.
Consider it only when all of the following hold:
pg_trgm with a GIN index, no MySQL FULLTEXT, no Meilisearch/Typesense/Elasticsearch, and adding one is disproportionate to the feature.LEVENSHTEIN routine (a compiled UDF or stored function). Managed offerings such as RDS/Aurora, Cloud SQL, and Azure Database generally forbid or gate this behind elevated parameter groups — a DBA/platform approval you should scope before, not after, committing to the approach.Look elsewhere when:
pg_trgm with a GIN index, MySQL full-text, or a dedicated engine — indexed fuzzy matching instead of per-row computation.levenshtein() or symfony/string's Levenshtein::distance() covers in-process comparison with no database dependency at all — this should be the default spike before any DB-side work.To executives: This is a small legacy utility, not a strategic dependency. It adds fuzzy string matching to database queries for internal tools — "did you mean…" and duplicate detection in back-office workflows — and it belongs in an existing Symfony 2 application, not on the roadmap as a component. Signal strength is low: 2 stars, no downstream users, and a target framework that has been unsupported since 2019. Recommendation: copy the roughly 50 lines of logic internally and keep the dependency count at zero. Cost is one engineering afternoon; the alternative is inheriting unmaintained code plus a database-platform approval we would have to negotiate anyway. If fuzzy search ever becomes a user-facing requirement, the migration target is a proper search index, and this function should be retired at that point — so treat any investment here as deliberately temporary.
To engineering: It is a Doctrine DQL custom function that exposes Levenshtein distance to the query builder. The value is ergonomic, not technical — the algorithm is trivial to reimplement — and the Symfony 2 bundle wrapper has no meaning in a modern container, so do not composer require it into main. Read the FunctionNode class as a specification and rewrite it against the Doctrine version we actually run, or skip the database entirely and use symfony/string or native levenshtein() in application code. Be explicit about the operational profile: it computes per row, cannot use an index, and becomes a sequential scan on any non-trivial table — fine behind an admin screen or a batch job, wrong for a public search endpoint. Three failure modes to design against: the server-side UDF missing on a newly provisioned or read-replica environment (production-only SQL errors), a managed-database policy change revoking the routine, and utf8mb4 collation mismatch causing silently incorrect distances rather than exceptions — the worst class, because results look plausible. Verify the platform permits CREATE ROUTINE, confirm the collation, assign internal ownership, and write tests; none of that comes with the package.
How can I help you explore Laravel packages today?