Sphinx Extension for Yii 2

This extension adds Sphinx full text search engine extension for the Yii framework 2.0. It supports all Sphinx features including Real-time Indexes.

For license information check the LICENSE-file.

Documentation is at docs/guide/README.md.

Latest Stable Version Total Downloads Build status


At least Sphinx version 2.0 is required. However, in order to use all extension features, Sphinx version 2.2.3 or higher is required.


The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yiisoft/yii2-sphinx

or add

"yiisoft/yii2-sphinx": "~2.0.0"

to the require section of your composer.json.


This extension interacts with Sphinx search daemon using MySQL protocol and SphinxQL query language. In order to setup Sphinx "searchd" to support MySQL protocol following configuration should be added:

    listen = localhost:9306:mysql41

To use this extension, simply add the following code in your application configuration:

return [
    'components' => [
        'sphinx' => [
            'class' => 'yii\sphinx\Connection',
            'dsn' => 'mysql:host=;port=9306;',
            'username' => '',
            'password' => '',

Class Reference

Class Description
yii\sphinx\ActiveDataProvider ActiveDataProvider is an enhanced version of yii\data\ActiveDataProvider specific to the Sphinx.
yii\sphinx\ActiveFixture ActiveFixture represents a fixture backed up by a ActiveRecord class or a Sphinx index.
yii\sphinx\ActiveQuery ActiveQuery represents a Sphinx query associated with an Active Record class.
yii\sphinx\ActiveRecord ActiveRecord is the base class for classes representing relational data in terms of objects.
yii\sphinx\ColumnSchema ColumnSchema class describes the metadata of a column in a Sphinx index.
yii\sphinx\Command Command represents a SQL statement to be executed against a Sphinx.
yii\sphinx\Connection Connection represents the Sphinx connection via MySQL protocol.
yii\sphinx\IndexSchema IndexSchema represents the metadata of a Sphinx index.
yii\sphinx\MatchBuilder MatchBuilder builds a MATCH SphinxQL expression based on the specification given as a yii\sphinx\MatchExpression object.
yii\sphinx\MatchExpression MatchExpression represents a MATCH SphinxQL expression.
yii\sphinx\Query Query represents a SELECT SQL statement.
yii\sphinx\QueryBuilder QueryBuilder builds a SELECT SQL statement based on the specification given as a yii\sphinx\Query object.
yii\sphinx\Schema Schema represents the Sphinx schema information.
yii\sphinx\gii\model\Generator This generator will generate one or multiple ActiveRecord classes for the specified Sphinx index.