PHPackages                             k2fl/sphinx-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. k2fl/sphinx-bundle

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

k2fl/sphinx-bundle
==================

Provides integration of Sphinx search engine with Symfony using SphinxQL

1.2.3(7y ago)044MITPHPPHP &gt;=7.1

Since May 22Pushed 7y ago2 watchersCompare

[ Source](https://github.com/k2fl/JaverSphinxBundle)[ Packagist](https://packagist.org/packages/k2fl/sphinx-bundle)[ Docs](https://github.com/k2fl/JaverSphinxBundle)[ RSS](/packages/k2fl-sphinx-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (2)Versions (12)Used By (0)

JaverSphinxBundle
=================

[](#javersphinxbundle)

This bundle provides integration of [Sphinx](http://sphinxsearch.com) search engine with Symfony.

Features:

- SphinxQL Query Builder
- Multi query support
- Integration with [doctrine/orm](https://packagist.org/packages/doctrine/orm)
- Integration with [knplabs/knp-paginator-bundle](https://packagist.org/packages/knplabs/knp-paginator-bundle)
- Symfony Profiler toolbar section with number of executed queries and profiler page with detailed information about executed queries
- Ability to test search using [Behat](https://packagist.org/packages/behat/behat) scenarios

Requirements
------------

[](#requirements)

- PHP 7.1+
- php\_mysqli php extension

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

[](#installation)

Install the bundle using composer:

```
composer require k2fl/sphinx-bundle
```

Configuration
-------------

[](#configuration)

Add to your `app/config/config.yml` the following options:

```
javer_sphinx:
    host: 127.0.0.1
    port: 9306
```

Full configuration with default values:

```
javer_sphinx:
    host: 127.0.0.1
    port: 9306
    config_path: "%kernel.root_dir%/config/sphinx.conf"
    data_dir: "%kernel.cache_dir%/sphinx"
    searchd_path: searchd
```

Usage
-----

[](#usage)

Synthetic example of SELECT query which returns an array:

```
$results = $this->container->get('sphinx')
    ->select('id', 'column1', 'column2', 'WEIGHT() as weight')
    ->from('index1', 'index2')
    ->where('column3', 'value1')
    ->where('column4', '>', 4)
    ->where('column5', [5, '6'])
    ->where('column6', 'NOT IN', [7, '8'])
    ->where('column7', 'BETWEEN', [9, 10])
    ->match('column8', 'value2')
    ->match(['column9', 'column10'], 'value3')
    ->groupBy('column11')
    ->groupBy('column12')
    ->withinGroupOrderBy('column13', 'desc')
    ->withinGroupOrderBy('column14')
    ->having('weight', '>', 2)
    ->orderBy('column15', 'desc')
    ->orderBy('column16')
    ->offset(5)
    ->limit(10)
    ->option('agent_query_timeout', 10000)
    ->option('max_matches', 1000)
    ->option('field_weights', '(column9=10, column10=3)')
    ->getResults();
```

Paginate a list of entities fetched from the database using Doctrine ORM QueryBuilder by searching phrase in them using Sphinx:

```
$queryBuilder = $this->container->get('doctrine.orm.default_entity_manager')
    ->createQueryBuilder()
    ->select('p', 'i')
    ->from('AppBundle:Product', 'p')
    ->join('AppBundle:Image', 'i')
    ->where('p.owner = :owner')
    ->setParameter('owner', $this->getUser());

$query = $this->container->get('sphinx')
    ->createQuery()
    ->select('*')
    ->from('product')
    ->match(['name', 'description'], $searchQuery)
    ->where('owner_id', $this->getUser()->getId())
    ->orderBy('created', 'desc')
    ->useQueryBuilder($queryBuilder, 'p');

$paginator = $this->container->get('knp_paginator')
    ->paginate($query, $request->query->get('page', 1), 20);
```

Sample shpinx.conf for the given example above:

```
source product
{
        type                    = mysql
        sql_host                = localhost
        sql_user                = user
        sql_pass                = password
        sql_db                  = database_name
        sql_query               = \
                SELECT p.id, p.owner_id, p.name, p.description, UNIX_TIMESTAMP(p.created) as created, \
                FROM product p \
                WHERE p.deletedAt IS NULL
        sql_attr_uint           = owner_id
        sql_attr_timestamp      = created
}

index product
{
        source                  = product
        path                    = /usr/local/var/data/product
        morphology              = stem_en
        min_stemming_len        = 3
}

```

Behat tests
===========

[](#behat-tests)

To be able to test search in Behat scenarios there is built-in behat context SphinxContext.

To use it you should add this context in your behat.yml, for example:

```
selenium:
    extensions:
        Behat\Symfony2Extension: ~
    suites:
        frontend:
            contexts:
                - Javer\SphinxBundle\Behat\Context\SphinxContext
```

Please note that Symfony2Extension Behat extension is required to be able to use this feature.

Then you should add a new step to your scenario:

```
Given I create search index and run sphinx

```

This step:

- creates a new configuration for sphinx based on your configuration
- converts all MySQL indexes to real-time indexes
- starts daemon
- loads data from the database to indexes for converted MySQL -&gt; real-time indexes
- stops daemon at the end of the scenario

Please note that you should explicitly declare all text fields in your indexes in the following form:

```
source product
{
    #!sql_field_string = name
}

```

It is not necessary when you declare fields for MySQL index in sphinx.conf, but it is needed to be able to convert indexes to real-time.

If you use sqlite as the database engine for running tests you should take into account that not all functions of the MySQL are presented in sqlite, so you should use portable analogs for these functions:

- `IF(condition, true, false)` -&gt; `CASE WHEN condition THEN true ELSE false END`
- and so on

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 52.6% 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 ~65 days

Recently: every ~74 days

Total

11

Last Release

2628d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.0

v1.1.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/334a39aa4db9781acfca243f9cbbdd7ab67165266c1bcce7b955237c8dd960a1?d=identicon)[k2fl](/maintainers/k2fl)

---

Top Contributors

[![k2fl](https://avatars.githubusercontent.com/u/9461114?v=4)](https://github.com/k2fl "k2fl (10 commits)")[![javer](https://avatars.githubusercontent.com/u/591296?v=4)](https://github.com/javer "javer (8 commits)")[![tacman](https://avatars.githubusercontent.com/u/619585?v=4)](https://github.com/tacman "tacman (1 commits)")

---

Tags

searchsymfonySymfony2doctrine2sphinxqlsphinx

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/k2fl-sphinx-bundle/health.svg)

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

###  Alternatives

[javer/sphinx-bundle

Provides integration of Sphinx search engine with Symfony using SphinxQL

24185.4k](/packages/javer-sphinx-bundle)[jolicode/elastically

Opinionated Elastica based framework to bootstrap PHP and Elasticsearch implementations.

2571.7M1](/packages/jolicode-elastically)[ripaclub/sphinxsearch

Sphinx Search library provides SphinxQL indexing and searching features

6232.2k3](/packages/ripaclub-sphinxsearch)[ddmaster/postgre-search-bundle

Tools to use full-text search PostgreSQL in Doctrine.

1289.9k](/packages/ddmaster-postgre-search-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)
