PHPackages                             demontpx/rigid-search-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. [Search &amp; Filtering](/categories/search)
4. /
5. demontpx/rigid-search-bundle

ActiveSymfony-bundle[Search &amp; Filtering](/categories/search)

demontpx/rigid-search-bundle
============================

Rigid search bundle for Symfony

0.7.4(5y ago)1389MITPHPPHP &gt;=7.4

Since Nov 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/DemonTPx/rigid-search-bundle)[ Packagist](https://packagist.org/packages/demontpx/rigid-search-bundle)[ RSS](/packages/demontpx-rigid-search-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (32)Used By (0)

DemonTPx rigid search bundle
============================

[](#demontpx-rigid-search-bundle)

Provides a way to make entities searchable.

Searches will be sorted by relevance which is calculated using the weight you can configure to the fields you index.

Installation
------------

[](#installation)

Require the bundle using composer:

```
composer require demontpx/rigid-search-bundle
```

Usage: Making an entity searchable
----------------------------------

[](#usage-making-an-entity-searchable)

Lets say we want to index a `NewsItem` entity:

```
class NewsItem {
    public function getId() { return $this->id; }
    public function getTitle() { return $this->title; }
    // ...
}
```

The first step is to create a new class which implements the `SearchDocumentExtractorInterface`. In here you define in which fields there needs to be searched and how important they are in relation to each other.

```
class NewsItemDocumentExtractor implements SearchDocumentExtractorInterface {
    public function extractDocument($item): Document {
        // $item should be of the type NewsItem

        // The title, description and URL you put in here are only used for display and link to the item
        // They are not searchable unless you add them as fields as well (see below!)
        $document = new Document(
            $item->getTitle(),
            $item->getDescription(),
            $item->getPublishDate(),
            $this->generateUrl($item)
        );

        // These are the fields on which items can be found
        // The last argument are the weight values, which can be any relative number
        $document->addField(new Field('title', $item->getTitle(), 1.0);
        $document->addField(new Field('text', $item->getText(), 0.8);
        $document->addField(new Field('category', $item->getCategoryName(), 0.2);
        $document->addField(new Field('tags', implode(' ', $item->getTagList()->toArray()), 0.25);

        return $document;
    }

    public function extractId($item): int {
        return $item->getId();
    }
}
```

Step two is to create another new class which implements the `ItemSearchManagerInterface`:

```
class NewsItemSearchManager implements ItemSearchManagerInterface {
    public function getClass(): string {
        // Classname of the entity
        return NewsItem::class;
    }

    public function getType(): string {
        // Short arbitrary unique name to describe the entity
        return 'news';
    }

    public function getDocumentExtractor(): SearchDocumentExtractorInterface {
        // Return the class created earlier
        // You could, of course, also inject the extractor into this class using the service container and pass it here
        return new NewsItemDocumentExtractor();
    }

    public function fetchAll(): array {
        // This method should return all searchable items of this type (ie: only published news items)
        // This is used when reindexing all items of this type
        // You should figure out for yourself where these entities should come from
        // For example: get these from an EntityRepository
        return $this->repository->fetchAllPublished();
    }
}
```

Register this class as a service in the container:

```
MyBundle\NewsItemSearchManager:
    tags: [demontpx_rigid_search.item_search_manager]
```

If everything is configured correctly, you should be able to index all `news` items using this command:

```
bin/console demontpx:search:reindex:type news
```

The next step is to trigger the index and remove manually when a news item is created, updated or removed. This could be achieved using events, or you could manually index and remove items from your search index in the controller:

```
class NewsItemController extends Controller {
    public function newAction() {
        $item = new NewsItem();
        // ... Do your persist logic here

        $searchManager = $this->get('demontpx_rigid_search.search_manager');
        $searchManager->index($item);
    }

    public function editAction(NewsItem $item) {
        // ... Do your persist logic here

        $searchManager = $this->get('demontpx_rigid_search.search_manager');
        $searchManager->index($item);
    }

    public function removeAction(NewsItem $item) {
        $oldId = $item->getId();

        // ... Do your remove logic here

        $searchManager = $this->get('demontpx_rigid_search.search_manager');
        $searchManager->remove($item);

        // Doctrine ORM resets the item id to null after a delete, so you might want to use this:
        $searchManager->removeByClassAndId(get_class($item), $oldId);
    }
}
```

Usage: Adding the search field and showing results
--------------------------------------------------

[](#usage-adding-the-search-field-and-showing-results)

The first step is to add this to your `routing.yaml`:

```
demontpx_rigid_search:
    resource: "@DemontpxRigidSearchBundle/Resources/config/routing.yml"
    prefix:   /search
```

After that you could add this to any of your twig templates:

```
{{ render(controller('Demontpx\\RigidSearchBundle\\Controller\\SearchController::searchForm', {}, { query: app.request.query.get('query', '') })) }}
```

Which will add the search input field. When submitted, this will show the search result.

The search result page will extend the `::base.html.twig` template by default. Override the whole template by creating `app/Resources/DemontpxRigidSearchBundle/views/Search/searchResult.html.twig`.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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

Every ~62 days

Recently: every ~101 days

Total

31

Last Release

1949d ago

PHP version history (5 changes)0.1PHP &gt;=5.5

0.2.1PHP ^5.5|^7.0

0.4PHP ^7.1

0.7PHP ^7.4

0.7.3PHP &gt;=7.4

### Community

Maintainers

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

---

Top Contributors

[![DemonTPx](https://avatars.githubusercontent.com/u/2570835?v=4)](https://github.com/DemonTPx "DemonTPx (37 commits)")

---

Tags

searchsymfonybundle

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/demontpx-rigid-search-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/demontpx-rigid-search-bundle/health.svg)](https://phpackages.com/packages/demontpx-rigid-search-bundle)
```

###  Alternatives

[jolicode/elastically

Opinionated Elastica based framework to bootstrap PHP and Elasticsearch implementations.

2571.7M1](/packages/jolicode-elastically)[dms/dms-filter-bundle

DMS Filter Bundle, makes Annotation based entity filtering available in Symfony

78351.6k1](/packages/dms-dms-filter-bundle)[cmsig/seal-symfony-bundle

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

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

Symfony filter bundle.

24459.9k1](/packages/bukashk0zzz-filter-bundle)[rollerworks/search-bundle

RollerworksSearch Bundle

1015.8k1](/packages/rollerworks-search-bundle)

PHPackages © 2026

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