PHPackages                             dezinger/yii2-rtsphinxbehavior - 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. dezinger/yii2-rtsphinxbehavior

ActiveYii2-extension[Search &amp; Filtering](/categories/search)

dezinger/yii2-rtsphinxbehavior
==============================

Yii2 Behavior for working with Sphinx RealTime index

283PHP

Since Mar 19Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Dezinger/yii2-rtsphinxbehavior)[ Packagist](https://packagist.org/packages/dezinger/yii2-rtsphinxbehavior)[ RSS](/packages/dezinger-yii2-rtsphinxbehavior/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Yii2 Behavior for working with Sphinx RealTime index
====================================================

[](#yii2-behavior-for-working-with-sphinx-realtime-index)

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

[](#installation)

The preferred way to install this extension is through [composer](https://getcomposer.org/).

Either run

```
php composer.phar require dezinger/yii2-rtsphinxbehavior

```

or add

```
"dezinger/yii2-rtsphinxbehavior": "dev-master"

```

to the require section of your composer.json file.

How to attach
-------------

[](#how-to-attach)

```
namespace modules\blog\models;
use modules\blog\Module;
use modules\blog\components\RtSphinxBehavior;

class Post extends \yii\db\ActiveRecord {

    public function behaviors() {
        return [
                    'rtSphinxBehavior' => [
                        'class' => RtSphinxBehavior::className(),
                        'rtIndex' => Yii::$app->getModule('blog')->getParam('sphinxRtIndex'),
                        'idAttributeName' => 'id',
                        'rtFieldNames' => [
                            'name',
                            'title',
                            'description',
                            'text'
                        ],
                        'rtAttributeNames' => [
                            'category_id', //RT attr and Post same name
                            'post_id' => 'id', //Attr mapping examle: rt.post_id = post.id
                            'parent_category_id' => 'category.parent_id', //Attr shortcut syntax example
                            'rating' => functon($model){return floatval($model->rating);}, //Usage closure example
                        ],
                        'enabled' => Yii::$app->getModule('blog')->getParam('isSphinxEnabled'),
                    ],
                ];
    }

```

In this very example the `rtIndex` parameter gets value from blog-module paramener `sphinxRtIndex`. Then provide the names of attributes and fields from our main document fetch query, that is described in sphinx.conf in the source block.

How to configure RT index for Sphinx
------------------------------------

[](#how-to-configure-rt-index-for-sphinx)

```
source is_src
{
	type			= mysql

	sql_host		= localhost
	sql_user		= root
	sql_pass		=
	sql_db			= cms_db
	sql_port		= 3306	# optional, default is 3306

	sql_query_pre = SET NAMES utf8
    sql_query_pre = SET CHARACTER SET utf8

	sql_query = \
		SELECT id, category_id, UNIX_TIMESTAMP(date) AS date, name, title, description, text \
		FROM post

	sql_attr_uint		= category_id

	sql_field_string    = name
	sql_field_string    = title
	sql_field_string    = description
	sql_field_string    = text
}

```

The configuration block for `RT` index looks like this:

```
index is_rt
{
	type			= rt
	docinfo			= extern

	rt_mem_limit	= 512M

	path			= /sphinx/data/is_rt
	stopwords		= /sphinx/stop/words.txt
	dict			= keywords
	morphology		= stem_ru, stem_en, soundex
	min_word_len	= 3
	min_prefix_len 	= 3
	expand_keywords	= 1
	index_exact_words = 1
	html_strip 		= 1

	rt_field = name
	rt_field = title
	rt_field = description
	rt_field = text

	rt_attr_uint = category_id
}

```

How it works
------------

[](#how-it-works)

`RtSphinxBehavior` triggers on insert | update | delete events, processed by `ActiveRecord` class.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 61.9% 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/641eb9bd32cf30aed6d545a62d2e784b02a123616f9b4d7350221c7559ed306b?d=identicon)[Dezinger](/maintainers/Dezinger)

---

Top Contributors

[![Dezinger](https://avatars.githubusercontent.com/u/432272?v=4)](https://github.com/Dezinger "Dezinger (13 commits)")[![IgorSalevan](https://avatars.githubusercontent.com/u/5684414?v=4)](https://github.com/IgorSalevan "IgorSalevan (8 commits)")

### Embed Badge

![Health badge](/badges/dezinger-yii2-rtsphinxbehavior/health.svg)

```
[![Health](https://phpackages.com/badges/dezinger-yii2-rtsphinxbehavior/health.svg)](https://phpackages.com/packages/dezinger-yii2-rtsphinxbehavior)
```

###  Alternatives

[ruflin/elastica

Elasticsearch Client

2.3k50.4M203](/packages/ruflin-elastica)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[massive/search-bundle

Massive Search Bundle

721.4M13](/packages/massive-search-bundle)[shyim/opensearch-php-dsl

OpenSearch/Elasticsearch DSL library

175.9M9](/packages/shyim-opensearch-php-dsl)[outl1ne/nova-multiselect-filter

Multiselect filter for Laravel Nova.

45802.7k3](/packages/outl1ne-nova-multiselect-filter)

PHPackages © 2026

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