PHPackages                             b0rner/yii2-solr - 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. b0rner/yii2-solr

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

b0rner/yii2-solr
================

Solr plugin for the Yii2 framework built on top of Solarium 6 and PHP 8

v3.0.0(7mo ago)1211BSD-3-ClausePHP

Since Feb 3Pushed 7mo agoCompare

[ Source](https://github.com/B0rner/yii2-solr)[ Packagist](https://packagist.org/packages/b0rner/yii2-solr)[ RSS](/packages/b0rner-yii2-solr/feed)WikiDiscussions master Synced 1mo ago

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

yii2-solr Extension
===================

[](#yii2-solr-extension)

A Yii2 Solr Extension built on top of [Solarium 6](https://solarium.readthedocs.io/en/stable/getting-started/) and PHP 8. This extension is based of the yii2-solr from Sammaye (), which unfortunately is not being developed further. Thanks Sammaye for the important work so far that has made it possible to use Solr elegantly in Yii2.

Unlike Sammaye's original extension, this version now provides ActiveRecord implementation for Solr data. This brings Solr document handling in line with Yii2's standard database ActiveRecord patterns, making it significantly easier and more intuitive to work with Solr. The ActiveRecord implementation provides familiar Yii2 patterns (`find()`, `findOne()`, `save()`, `delete()`, etc.), eliminates boilerplate code, and includes full ActiveDataProvider and ActiveFixture support.

This code is provided as is, and no guarantee is given, also no warranty/guarantee, that this code will preform in the desired way.There will be no guarantee that there will be patches for this software in the future.

This extension tries to mimic Yii's database bahavior as close as possible. As Yii provides different ways to query SQL databases, this extension does the same with SOLR. Nevertheless SQL databases and SOLR are different in many ways - so there have to be compromises.

By no means this extension covers all possibilities of SOLR nor of Solarium.

Installation
============

[](#installation)

Composer ToDo

Setup
=====

[](#setup)

First one has to add the extension to the Yii2 configuration under `components`:

```
        'solr' => [
            'class' => 'b0rner\solr\Connection',
            'options' => [
                'endpoint' => [
                    'solr1' => [
                        'host' => 'solr',
                        'port' => '8983',
                        'path' => '/',
                        'collection' => 'my_collection'
                    ]
                ]
            ]
        ],
```

The `options` part of the configuration is a one-to-one match to Solariums own constructor and options. See [documentation](https://solarium.readthedocs.io/en/stable/client-and-adapters/)

Working with Query Class
========================

[](#working-with-query-class)

A simple way to query the SOLR index is the Query Class. It provides an easy way to get documents out of an index:

```
