PHPackages                             dompat/stemmer-bundle - 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. [Templating &amp; Views](/categories/templating)
4. /
5. dompat/stemmer-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

dompat/stemmer-bundle
=====================

Symfony integration for the PHP Stemmer. Includes Twig filters, automatic driver registration and YAML configuration.

v1.0.0(2mo ago)11MITPHPPHP ^8.3CI passing

Since Feb 26Pushed 2mo agoCompare

[ Source](https://github.com/domPatera/stemmer-bundle)[ Packagist](https://packagist.org/packages/dompat/stemmer-bundle)[ RSS](/packages/dompat-stemmer-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

Stemmer Bundle for Symfony
==========================

[](#stemmer-bundle-for-symfony)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2c150fdaa41e0652134fd52d4e9d9f44d8b439d9d2d1b6f76d8820987a8953af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646f6d7061742f7374656d6d65722d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dompat/stemmer-bundle)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/9b1c2ec370d2da74a2681f72145815e4b88d9bab5a95ae327e2170dc122fc6b4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e332d3838393262662e7376673f7374796c653d666c61742d737175617265)](https://php.net)[![Symfony Version](https://camo.githubusercontent.com/43611743f11d6ea67398fdb112d69d06c2c497abc06dda37606dcf19e86b42ae/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73796d666f6e792d253545362e34253230253743253230253545372e30253230253743253230253545382e302d3030303030302e7376673f7374796c653d666c61742d737175617265)](https://symfony.com)

This bundle integrates the [dompat/stemmer](https://github.com/dompat/stemmer) library into Symfony. It provides automatic service registration, Twig filters and easy configuration for language drivers.

✨ Features
----------

[](#-features)

- **Automatic Driver Registration:** Registers all drivers provided by [dompat/drivers](https://github.com/dompat/stemmer).
- **Twig Support:** Simple `|stem` filter for your templates.
- **Configurable Contexts:** Map custom locales to specific drivers via YAML.
- **Autoconfiguration:** Just implement `DriverInterface` to add your own drivers.
- **Driver Priority:** Easily override core drivers with your own implementation.

🚀 Installation
--------------

[](#-installation)

Install the bundle via [Composer](https://getcomposer.org/):

```
composer require dompat/stemmer-bundle
```

Enable the bundle in `config/bundles.php`:

```
return [
    // ...
    Dompat\StemmerBundle\DompatStemmerBundle::class => ['all' => true],
];
```

📖 Usage
-------

[](#-usage)

### Using the Service

[](#using-the-service)

You can inject `Dompat\Stemmer\Stemmer` into your services or controllers:

```
use Dompat\Stemmer\Stemmer;
use Dompat\Stemmer\Enum\StemmerMode;

public function search(string $query, Stemmer $stemmer)
{
    $stemmed = $stemmer->stem($query, 'cs', StemmerMode::AGGRESSIVE);
    // ...
}
```

### Using Twig

[](#using-twig)

The bundle provides a `stem` filter:

```
{# Simple usage (uses LIGHT mode by default) #}
{{ 'working'|stem('en') }} {# output: work #}

{# With explicit mode #}
{{ 'declaration'|stem('en', 'aggressive') }} {# output: declar #}
```

Available modes: `light` (default), `aggressive`.

⚙️ Configuration
----------------

[](#️-configuration)

By default, the bundle registers all drivers found in [dompat/stemmer](https://github.com/dompat/stemmer). You can add custom mapping or override default drivers in `config/packages/dompat_stemmer.yaml`:

```
dompat_stemmer:
    contexts:
        sk: Dompat\Stemmer\Driver\CzechDriver  # Use Czech rules for Slovak language
        en: App\Stemmer\MyCustomEnglishDriver  # Force your custom driver for English
```

🌍 Adding Custom Drivers
-----------------------

[](#-adding-custom-drivers)

To add a new language driver, implement `Dompat\Stemmer\Contract\DriverInterface`.

### Autowiring and Priority

[](#autowiring-and-priority)

If you use autoconfiguration (default in Symfony), your driver will be automatically registered with the `Stemmer` manager.

Custom drivers have a higher priority by default. This means if you create your own `EnglishDriver`, it will automatically replace the original one from the library without any extra configuration.

If you want to use a specific driver for a locale (e.g., to switch back to the original one or map a different class), use the `contexts` configuration shown above.

```
namespace App\Stemmer;

use Dompat\Stemmer\Contract\DriverInterface;
use Dompat\Stemmer\Contract\StemmerModeInterface;

class FrenchDriver implements DriverInterface
{
    public function getLocale(): string
    {
        return 'fr';
    }

    public function stem(string $word, StemmerModeInterface $mode): string
    {
        // ... your implementation
    }

    public function __toString(): string
    {
        return 'FrenchDriver';
    }
}
```

📄 License
---------

[](#-license)

This bundle is licensed under the [MIT License](LICENSE).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance85

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

80d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a3b81c4a23385a9b975b9500417a3f7ad4c6eeab70be517db41239b7c5bbbe74?d=identicon)[domPatera](/maintainers/domPatera)

---

Top Contributors

[![domPatera](https://avatars.githubusercontent.com/u/118061276?v=4)](https://github.com/domPatera "domPatera (7 commits)")

---

Tags

bundleczechenglishindexingnlpphpsearchstemmersymfonytext-analysissearchtwigextensionnlpSymfony Bundleindexingstemmerstemming

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dompat-stemmer-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/dompat-stemmer-bundle/health.svg)](https://phpackages.com/packages/dompat-stemmer-bundle)
```

###  Alternatives

[iq2i/storia-bundle

UI Storia bundle

144.6k](/packages/iq2i-storia-bundle)[cmsig/seal-symfony-bundle

An integration of CMS-IG SEAL search abstraction into Symfony Framework.

15195.8k5](/packages/cmsig-seal-symfony-bundle)

PHPackages © 2026

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