PHPackages                             gnugat/search-engine - 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. gnugat/search-engine

AbandonedLibrary[Search &amp; Filtering](/categories/search)

gnugat/search-engine
====================

Component that tries to help you get the Query part in CQRS right

v0.3.0(10y ago)21062MITPHPPHP ^7.0

Since Aug 21Pushed 10y ago2 watchersCompare

[ Source](https://github.com/gnugat/search-engine)[ Packagist](https://packagist.org/packages/gnugat/search-engine)[ Docs](http://gnugat.github.io/search-engine)[ RSS](/packages/gnugat-search-engine/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (7)Used By (2)

Search Engine [![SensioLabsInsight](https://camo.githubusercontent.com/a01e2c551100102c504bc9791aac3e1a324f395d499be080224b7eff51c5ae1b/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f30626632336261662d623237382d346265312d396532302d3061313234373262623065642f6d696e692e706e67)](https://insight.sensiolabs.com/projects/0bf23baf-b278-4be1-9e20-0a12472bb0ed) [![Build Status](https://camo.githubusercontent.com/967685751d95bde9396cebfe15ea0ee9baf236160737e01fb194c17521dc9a5d/68747470733a2f2f7472617669732d63692e6f72672f676e756761742f7365617263682d656e67696e652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/gnugat/search-engine)
==============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#search-engine--)

A Proof Of Concept demonstrating how to handle Interrogatory Messages (Query in CQRS).

The [Command / Query Responsibility Segregation](http://martinfowler.com/bliki/CQRS.html)principle explains that Imperative and Interrogatory messages shouldn't be mixed together.

> **Note**: Learn more about the different [messaging flavours](http://verraes.net/2015/01/messaging-flavours/).

[Usually imperative messages are handled using the CommandBus pattern](https://gnugat.github.io/2016/05/11/towards-cqrs-command-bus.html), which leaves us with the following question: how Interrogatory Messages should be handled?

[This component tries to explore one of the possible answers](https://gnugat.github.io/2016/05/18/towards-cqrs-search-engine.html): a SearchEngine that would try to return results matching a given criteria.

> **Caution**: this component does not provide actual SearchEngine features, if you're looking for one you should rather have a look at ElasticSearch, Solr, etc.

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

[](#installation)

Download SearchEngine using [Composer](https://getcomposer.org/download):

```
composer require gnugat/search-engine:^0.3

```

You'll also need to choose one of the following implementations:

- [PommSearchEngine](https://github.com/gnugat/pomm-search-engine), a [Pomm Foundation](http://www.pomm-project.org/) implementation
- hey you just met this library, and this is crazy, but it has interfaces, so implement them, maybe?

Other possible implementations: PDO, [Doctrine DBAL](https://gnugat.github.io/2016/05/18/towards-cqrs-search-engine.html), Doctrine ORM, etc. In the `tests` directory you'll find an `Array` implementation example.

[More information about implementations](doc/01-implementing.md)

Usage
-----

[](#usage)

`SearchEngine` expects a `Criteria` object which describes:

- the resource to query
- relations to embed
- filters to apply
- orderings instructions
- pagination parameters

It can be built from query parameters as follow:

```
// ...
$criteria = $criteriaFactory->fromQueryParameters('blog', [
    // Filters
    'title' => 'IG',
    'author_ids' => '1,3',

    // Pagination
    'page' => '2',
    'per_page' => '3',

    // Ordering
    'sort' => 'author_id,-title',

    // Relation embeding
    'embed' => 'author',
]);
print_r(iterator_to_array(
    $searchEngine
        ->match($criteria)
        ->take(
            $criteria->paginating->offset,
            $criteria->paginating->itemsPerPage
        )
        ->getIterator()
));
```

In a web context, this `$queryParameters` array could actually be `$_GET`, corresponding to the following URL:

```
/v1/blogs?title=IG&author_ids=1,2&page=1&per_page=3&sort=author_id,-title&embed=author

```

The result could be the following:

```
[
    'items' => [
        [
            'id' => 1,
            'title' => 'Big Title',
            'author_id' => 1,
        ],
        [
            'id' => 2,
            'title' => 'Big Header',
            'author_id' => 2,
        ],
    ],
    'page' => [
        'current_page' => 1,
        'per_page' => 3,
        'total_elements' => 2,
        'total_pages' => 1,
    ],
]

```

Further documentation
---------------------

[](#further-documentation)

You can see the current and past versions using one of the following:

- the `git tag` command
- the [releases page on Github](https://github.com/gnugat/search-engine/releases)
- the file listing the [changes between versions](CHANGELOG.md)

You can find more documentation at the following links:

- [copyright and MIT license](LICENSE)
- [versioning and branching models](VERSIONING.md)
- [contribution instructions](CONTRIBUTING.md)

Next readings:

- [Implementing](doc/01-implementing.md)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

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

Every ~54 days

Recently: every ~68 days

Total

6

Last Release

3651d ago

PHP version history (3 changes)v0.1.0PHP ^5.3.2

v0.2.3PHP ^5.3.2|^7.0

v0.3.0PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/34578c5e0a3bc10fb9ef6e3a3a0b3356d6cde1133c8fa0e090d0a99298df1f76?d=identicon)[gnupat](/maintainers/gnupat)

---

Top Contributors

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

---

Tags

cqrssearch enginequery-businterrogatory message

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gnugat-search-engine/health.svg)

```
[![Health](https://phpackages.com/badges/gnugat-search-engine/health.svg)](https://phpackages.com/packages/gnugat-search-engine)
```

###  Alternatives

[ppshobi/psonic

PHP client for Sonic Search Engine

13494.8k3](/packages/ppshobi-psonic)[opensearchserver/opensearchserver

PHP library for OpenSearchServer: professionnal search engine, crawlers (web, file, database), REST APIs, .... This library uses OpenSearchServer's V2 API.

5267.5k](/packages/opensearchserver-opensearchserver)[nilportugues/sphinx-search

Fully unit tested SphinxClient (SphinxAPI) for PHP5.3 and above to be used with SphinxSearch

18452.9k2](/packages/nilportugues-sphinx-search)[ripaclub/sphinxsearch

Sphinx Search library provides SphinxQL indexing and searching features

6232.2k3](/packages/ripaclub-sphinxsearch)[algolia/laravel-scout-algolia-macros

A collection macros to extend Laravel Scout with more Algolia capabilities

3633.7k](/packages/algolia-laravel-scout-algolia-macros)[ymigval/laravel-indexnow

Laravel Service Library for notifying search engines about the latest content changes on their URLs using IndexNow.

3410.2k](/packages/ymigval-laravel-indexnow)

PHPackages © 2026

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