PHPackages                             glanchow/doctrine-fuzzy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. glanchow/doctrine-fuzzy

ActiveLibrary

glanchow/doctrine-fuzzy
=======================

Doctrine2 DQL fuzzy functions

336.0k↓50%2[3 issues](https://github.com/glanchow/doctrine-fuzzy/issues)PHP

Since Nov 8Pushed 11y ago1 watchersCompare

[ Source](https://github.com/glanchow/doctrine-fuzzy)[ Packagist](https://packagist.org/packages/glanchow/doctrine-fuzzy)[ RSS](/packages/glanchow-doctrine-fuzzy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

doctrine-fuzzy
==============

[](#doctrine-fuzzy)

Provides Doctrine DQL fuzzy functions :

- **LEVENSHTEIN**
- **MATCH AGAINST**
- **SOUNDEX**

Installation
============

[](#installation)

### Installing with composer

[](#installing-with-composer)

Edit composer.json

```
    "require": {
    …
        "glanchow/doctrine-fuzzy": "*"
    …
    }
```

Then update

```
    php composer.phar update
```

Symfony2 configuration
======================

[](#symfony2-configuration)

Edit app/config/config.yml

```
doctrine:
    orm:
        entity_managers:
            default:
                dql:
                    numeric_functions:
                        LEVENSHTEIN: WOK\Doctrine\Query\LevenshteinFunction
                        LEVENSHTEIN_RATIO: WOK\Doctrine\Query\LevenshteinRatioFunction
                    string_functions:
                        MATCH: WOK\Doctrine\Query\MatchAgainstFunction
                        SOUNDEX: WOK\Doctrine\Query\SoundexFunction
```

Usage
=====

[](#usage)

```
   /**
    * Suggest Geoname
    */
    public function suggestGeoname($q, $offset, $limit)
    {
        $query = $this->_em
            ->createQueryBuilder('g')
            ->select('g, LEVENSHTEIN(g.name, :q) AS d')
            ->from($this->_entityName, 'g')
            ->orderby('d', 'ASC')
            ->setFirstResult($offset)
            ->setMaxResults($limit)
            ->setParameter('q', $q)
            ->getQuery();

        return $query->getResult();
    }
```

Levenshtein
===========

[](#levenshtein)

If Levenshtein functions are not shipped with your database configuration

Start your SQL client

```
    mysql
```

Select the database on which you want to add the LEVENSHTEIN functions

```
    USE database;
```

Add the functions

```
DELIMITER ;;;
CREATE FUNCTION LEVENSHTEIN(s1 VARCHAR(255), s2 VARCHAR(255)) RETURNS int(11) DETERMINISTIC
BEGIN
    DECLARE s1_len, s2_len, i, j, c, c_temp, cost INT;
    DECLARE s1_char CHAR;
    DECLARE cv0, cv1 VARBINARY(256);
    SET s1_len = CHAR_LENGTH(s1), s2_len = CHAR_LENGTH(s2), cv1 = 0x00, j = 1, i = 1, c = 0;
    IF s1 = s2 THEN
        RETURN 0;
    ELSEIF s1_len = 0 THEN
        RETURN s2_len;
    ELSEIF s2_len = 0 THEN
        RETURN s1_len;
    ELSE
        WHILE j  s2_len THEN SET max_len = s1_len; ELSE SET max_len = s2_len; END IF;
    RETURN ROUND((1 - LEVENSHTEIN(s1, s2) / max_len) * 100);
END
;;;
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d319e1b6d2fd1004df4e7ac2840d8f7efe03a77bc12a1018a11837dc6bc40348?d=identicon)[allan-simon](/maintainers/allan-simon)

---

Top Contributors

[![glanchow](https://avatars.githubusercontent.com/u/1622353?v=4)](https://github.com/glanchow "glanchow (4 commits)")[![allan-simon](https://avatars.githubusercontent.com/u/213167?v=4)](https://github.com/allan-simon "allan-simon (1 commits)")

### Embed Badge

![Health badge](/badges/glanchow-doctrine-fuzzy/health.svg)

```
[![Health](https://phpackages.com/badges/glanchow-doctrine-fuzzy/health.svg)](https://phpackages.com/packages/glanchow-doctrine-fuzzy)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
