- How do I install rap2hpoutre/similar-text-finder in a Laravel project?
- Install it with composer require rap2hpoutre/similar-text-finder and call the classes directly in your code. There is no Laravel service provider, config file, or published asset, so nothing needs registering in config/app.php. Treat it as a small plain PHP dependency rather than a Laravel package.
- Does similar-text-finder work with Laravel 10 or 11 and PHP 8.2 or 8.3?
- The package is framework-agnostic plain PHP, so it is not tied to a Laravel version, but the last release was in 2019 and PHP 8.x compatibility must be verified before you commit. Run a spike against your exact PHP 8.2 or 8.3 runtime and Laravel version, check composer.json platform constraints, and avoid --ignore-platform-reqs in production. If constraints block installation, fork or copy the class with MIT attribution.
- What algorithms does similar-text-finder use to compare strings?
- It runs several comparison algorithms, including Levenshtein, similar_text, Smith-Waterman, and Jaro-Winkler, and combines their scores into a normalized similarity value. That multi-metric approach is intended to make fuzzy matching more reliable than relying on a single algorithm. The API stays small: compare two strings for a percentage-style score or search an array of candidates.
- How do I find the closest match for a string in an array of candidates?
- You pass a query string and an array of candidates, and the package ranks them to return the closest match. Because it works on an in-memory candidate list, keep that list bounded and pre-filter database records in SQL before calling it. Check the README for the exact method signature in your pinned version.
- Can I use similar-text-finder for fuzzy search instead of Meilisearch or Algolia?
- It is suitable for bounded fuzzy lookups such as admin typo suggestions, small autocomplete lists, or one-off cleanup jobs, not as a replacement for an indexed search engine. Cost grows linearly with candidate count and request volume, so loading entire tables or serving high-QPS traffic will be slow. Pre-filter candidates in SQL by prefix, trigram, or category, cap the list, and cache frequent suggestions.
- Is similar-text-finder safe for production if it has not been updated since 2019?
- The main risk is lifecycle, not code complexity: the package is stale, low-popularity, and has no visible maintenance cadence. Pin the exact version, commit the lockfile, run unit tests on representative inputs, and wrap it behind an internal service so a fork or replacement is cheap. The MIT license allows vendoring or forking if you need to patch compatibility.
- Does similar-text-finder support Unicode, accents, or non-Latin characters?
- Unicode and accent handling are not documented, and PHP's native levenshtein and similar_text functions are byte-oriented, so multibyte input needs care. Normalize inputs in your wrapper, including lowercasing, trimming, transliterating accents, and deciding how to handle non-Latin scripts, before comparing. Test with representative names, product titles, and languages rather than assuming the score is meaningful.
- How do I add a minimum similarity threshold so similar-text-finder does not return false positives?
- The package can return a closest match even when nothing is genuinely similar, so false positives are expected without your own threshold. Wrap the call, reject results below an acceptable score, and validate matches before acting on them. Tune the threshold against a labeled test corpus for each feature.
- Is similar-text-finder a good fit for deduplication or spell-check suggestions?
- Yes, it fits deduplication, typo suggestions, form validation hints, and small autocomplete lists where the candidate set is bounded. Put it behind a SimilarTextFinderService that owns normalization, candidate limits, thresholds, ranking, and fallback behavior instead of calling the package from controllers or jobs. Add caching for frequent queries and benchmark with your expected candidate counts.
- What are the alternatives to similar-text-finder for fuzzy matching in Laravel?
- For simple cases, native similar_text or levenshtein may be enough, while larger or high-QPS fuzzy search usually calls for a proper search service or database trigram indexing. The package's advantage is combining multiple algorithms into one normalized score for more robust small-scale matching. Weigh that against its stale maintenance and decide whether to keep, fork, or replace after a one-day spike.