PHPackages                             cornernote/yii-sphinx - 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. cornernote/yii-sphinx

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

cornernote/yii-sphinx
=====================

Yii extension for Sphinx Search.

1.1.0(11y ago)22.5k5[1 issues](https://github.com/cornernote/yii-sphinx/issues)BSD-3-ClausePHP

Since Jun 13Pushed 4y ago2 watchersCompare

[ Source](https://github.com/cornernote/yii-sphinx)[ Packagist](https://packagist.org/packages/cornernote/yii-sphinx)[ RSS](/packages/cornernote-yii-sphinx/feed)WikiDiscussions master Synced 1mo ago

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

yii-sphinx
==========

[](#yii-sphinx)

Yii extension for Sphinx Search

forked from

```
return array(
    'aliases' => array(
        'sphinx' => realpath(VENDOR_PATH . '/cornernote/yii-sphinx/sphinx'),
    ),
    'components' => array(
        'sphinx' => array(
            'class' => 'sphinx.components.ESphinxSearch',
            'server' => '127.0.0.1',
            'port' => 9312,
            'maxQueryTime' => 3600,
            'enableProfiling' => YII_DEBUG,
            'enableResultTrace' => YII_DEBUG,
        ),
       'dbSphinx' => array(
            'class' => 'sphinx.components.ESphinxDbConnection',
            'connectionString' => 'mysql:host=127.0.0.1;port=9306',
            'emulatePrepare' => true,
            'charset' => 'utf8',
            'schemaCachingDuration' => 3600,
            'enableProfiling' => YII_DEBUG,
            'enableParamLogging' => YII_DEBUG,
        ),
     ),
);
```

Search by criteria Object:

```
// create the criteria
$searchCriteria = new ESphinxCriteria();
$searchCriteria->select = 'id';
$searchCriteria->filters = array('status' => 1);
$searchCriteria->query = 'keywords';
$searchCriteria->from = 'product';
$searchCriteria->groupby = 'id';
$searchCriteria->orders = array('name' => 'ASC');
$searchCriteria->paginator->pageSize = 1000;
$searchCriteria->fieldWeights = array(
    'name' => 20,
    'description' => 1,
);

// get the result
$resIterator = Yii::app()->sphinx->search($searchCriteria); // interator result
// or
$resArray = Yii::app()->sphinx->searchRaw($searchCriteria); // array result
```

Search by SQL-like syntax:

```
$search->select('*')->
    from($indexName)->
    where($expression)->
    filters(array('project_id' => $this->_city->id))->
    groupby($groupby)->
    orderby(array('f_name' => 'ASC'))->
    limit(0, 30);
$resIterator = $search->search(); // interator result
/* OR */
$resArray = $search->searchRaw(); // array result
```

Search by SphinxClient syntax:

```
$search = Yii::App()->search;
$search->setSelect('*');
$search->setArrayResult(false);
$search->setMatchMode(SPH_MATCH_EXTENDED);
$search->setFieldWeights($fieldWeights)
$resArray = $search->query( $query, $indexName);
```

Combined Method:

```
$search = Yii::App()->search->
    setArrayResult(false)->
    setMatchMode(SPH_MATCH_EXTENDED);
$resIterator = $search->select('field_1, field_2')->search($searchCriteria);
```

Finding Models:

```
$ids = array_keys($resArray['matches']);
$criteria = new CDbCriteria;
$criteria->addInCondition('id', $ids);
$criteria->order = 'FIELD(t.id, ' . implode(', ', $ids) . ')'; // order by weight
$products = Product::model()->findAll($criteria);
```

Real-Time Index via ActiveRecord:

```
class Product extends CActiveRecord
{

    public function tableName()
    {
        return 'product';
    }

    public function afterSave()
    {
        ProductIndex::model()->updateIndex($this);
        parent::afterSave();
    }

    public function afterDelete()
    {
        ProductIndex::model()->deleteIndex($this);
        parent::afterDelete();
    }

}

class ProductIndex extends ESphinxActiveRecord
{

    public function tableName()
    {
        return 'product';
    }

    public function truncateIndex()
    {
        $this->dbConnection->createCommand('TRUNCATE RTINDEX ' . ProductIndex::model()->tableName())->execute();
    }

    public function deleteIndex($product)
    {
        $this->dbConnection->createCommand("DELETE FROM " . ProductIndex::model()->tableName() . " WHERE id = " . $product->id)->execute();
    }

    public function updateIndex($product)
    {
        $productIndex = new ProductIndex();
        $productIndex->id = $product->id;
        $productIndex->name = $product->name;
        $productIndex->description = $product->description;
        $productIndex->status = $product->status;
        $productIndex->save(false);
    }

}
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

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 ~31 days

Total

2

Last Release

4326d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/07c84a589344489e8195ec1c6afcfa3abcc23a73092ceaa4ca60da96355c4d16?d=identicon)[cornernote](/maintainers/cornernote)

---

Top Contributors

[![cornernote](https://avatars.githubusercontent.com/u/51875?v=4)](https://github.com/cornernote "cornernote (27 commits)")

---

Tags

searchyiisphinxsphinxsearchmrphp

### Embed Badge

![Health badge](/badges/cornernote-yii-sphinx/health.svg)

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

###  Alternatives

[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)[javer/sphinx-bundle

Provides integration of Sphinx search engine with Symfony using SphinxQL

24185.4k](/packages/javer-sphinx-bundle)

PHPackages © 2026

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