PHPackages                             black-lamp/yii2-search - 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. black-lamp/yii2-search

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

black-lamp/yii2-search
======================

Component for search in Active Record models

2.0.2(9y ago)32061[1 issues](https://github.com/black-lamp/yii2-search/issues)BSD-3-ClausePHP

Since Sep 21Pushed 9y ago2 watchersCompare

[ Source](https://github.com/black-lamp/yii2-search)[ Packagist](https://packagist.org/packages/black-lamp/yii2-search)[ RSS](/packages/black-lamp-yii2-search/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (4)Versions (13)Used By (0)

Component for search in Active Record model
===========================================

[](#component-for-search-in-active-record-model)

[![Build Status](https://camo.githubusercontent.com/75b028d11d357337a6be139e26650dc822a13517a45f5077ca7fab5b25fda272/68747470733a2f2f7472617669732d63692e6f72672f626c61636b2d6c616d702f796969322d7365617263682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/black-lamp/yii2-search)[![Latest Stable Version](https://camo.githubusercontent.com/6687efec52da6e41bd7c3b1841b62e916e13e9103852515d6dfa518155af15ed/68747470733a2f2f706f7365722e707567782e6f72672f626c61636b2d6c616d702f796969322d7365617263682f762f737461626c65)](https://packagist.org/packages/black-lamp/yii2-search)[![Latest Unstable Version](https://camo.githubusercontent.com/dd952bb20a87cbc1dee0dad8573fe6c98d08d02527dc796e262b9bb2294465b2/68747470733a2f2f706f7365722e707567782e6f72672f626c61636b2d6c616d702f796969322d7365617263682f762f756e737461626c65)](https://packagist.org/packages/black-lamp/yii2-search)[![License](https://camo.githubusercontent.com/cb76beedcf7ac143d3144e127c4a679718178288c49618ab8597d321d0476467/68747470733a2f2f706f7365722e707567782e6f72672f626c61636b2d6c616d702f796969322d7365617263682f6c6963656e7365)](https://packagist.org/packages/black-lamp/yii2-search)

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

[](#installation)

Run command

```
composer require black-lamp/yii2-search

```

or add

```
"black-lamp/yii2-search": "^2.0.0"
```

to the require section of your composer.json.

#### Add 'SiteSearch' component to application config

[](#add-sitesearch-component-to-application-config)

```
'components' => [
      // ...
      'search' => [
            'class' => bl\search\SearchComponent::class,
            // models where you need the search
            'models' => [
                'article' => [
                    'class' => frontend\models\Article::class,
                    'label' => 'Articles'
                 ],
                // ...
            ]
      ],
]
```

To models array you should to add the active record models where component will be make a search.

`class` it's a model's name.

`label` it's a title for displaying in view.

#### Implement [interface](https://github.com/black-lamp/yii2-search/blob/master/src/interfaces/SearchInterface.php) in the models where you need a search

[](#implement-interface-in-the-models-where-you-need-a-search)

```
/**
 * @property integer $id
 * @property string $title
 * @property string $shortText
 * @property string $fullText
 * @property string $socialNetworksText
 */
class Article extends ActiveRecord implements \bl\search\interfaces\SearchInterface
{
    // ...

    /**
     * @inheritdoc
     */
    public function getSearchTitle() {
        return $this->title;
    }

    /**
     * @inheritdoc
     */
    public function getSearchDescription() {
        return $this->shortText;
    }

    /**
     * @inheritdoc
     */
    public function getSearchUrl() {
       return Url::toRoute["/articles/$this->id"];
    }

   /**
    * @inheritdoc
    */
    public function getSearchFields() {
        return [
            'title',
            'shortText',
            'fullText'
        ];
    }
}
```

Using
-----

[](#using)

Call method for getting a search results. This method return a [SearchResult](https://github.com/black-lamp/yii2-search/blob/master/src/data/SearchResult.php) objects in array.

```
/**
 * @var \bl\search\data\SearchResult[] $result
 */
$result = Yii::$app->searcher->search('Black lamp');

foreach($result as $res) {
    $res->title;
    $res->description;
    $res->url;
}
```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 95.5% 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 ~21 days

Recently: every ~42 days

Total

12

Last Release

3339d ago

Major Versions

0.3.1-beta → 1.0.02016-10-18

1.1.1 → 2.0.02017-01-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e1784ec992318bf7ed40a2025a0ca035a01143de89054f0f4c9bc39469928c1?d=identicon)[GutsVadim](/maintainers/GutsVadim)

---

Top Contributors

[![greeflas](https://avatars.githubusercontent.com/u/17636915?v=4)](https://github.com/greeflas "greeflas (21 commits)")[![GutsVadim](https://avatars.githubusercontent.com/u/9513738?v=4)](https://github.com/GutsVadim "GutsVadim (1 commits)")

---

Tags

black-lampphpyii-extensionyii2searchrecordyii2componentactive

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/black-lamp-yii2-search/health.svg)

```
[![Health](https://phpackages.com/badges/black-lamp-yii2-search/health.svg)](https://phpackages.com/packages/black-lamp-yii2-search)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[vintage/yii2-search

Search in Active Record models for Yii2

294.6k](/packages/vintage-yii2-search)

PHPackages © 2026

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