PHPackages                             ibraimv/laravel-solr-integration - 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. [API Development](/categories/api)
4. /
5. ibraimv/laravel-solr-integration

ActiveLibrary[API Development](/categories/api)

ibraimv/laravel-solr-integration
================================

A Laravel package for seamless Solr integration

v1.0.3(1y ago)018MITPHPPHP ^8.0

Since Nov 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/IbraimV/laravel-solr-integration)[ Packagist](https://packagist.org/packages/ibraimv/laravel-solr-integration)[ RSS](/packages/ibraimv-laravel-solr-integration/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (3)Used By (0)

Solr Integration for Laravel
============================

[](#solr-integration-for-laravel)

This package provides an easy-to-use Solr client for Laravel, allowing you to interact with an Apache Solr server. It facilitates document addition, bulk operations, and search queries, making it simple to integrate Solr with Laravel applications.

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

[](#installation)

### Step 1: Install the Package

[](#step-1-install-the-package)

Install via Composer:

```
composer require ibraimv/laravel-solr-integration
```

### Step 2: Publish Configuration

[](#step-2-publish-configuration)

Publish the Solr configuration file:

```
php artisan vendor:publish --provider="Ibraimv\SolrIntegration\SolrServiceProvider" --tag="config"
```

### Step 3: Configure Environment Variables

[](#step-3-configure-environment-variables)

Publish the Solr configuration file:

```
SOLR_BASE_URI="http://localhost:8983/solr"
SOLR_DEFAULT_COLLECTION="my_collection"
SOLR_DEFAULT_PARAMS='{"defType":"edismax","sort":"score desc"}'
```

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

```
use Ibraimv\SolrIntegration\Facades\Solr;

// Add a document
Solr::addDocument([
    'id' => '123',
    'title' => 'Sample Document',
    'description' => 'This is a sample document.',
]);

// Bulk add documents
Solr::bulkAddDocuments([
    ['id' => '124', 'title' => 'Second Document'],
    ['id' => '125', 'title' => 'Third Document'],
]);

// Search documents
$response = Solr::search('title:Sample', [
    'fq' => 'description:document',
    'sort' => 'score desc',
    'rows' => 10,
]);

// Delete a document by ID
Solr::deleteSingleDocument('123');

// Delete a document by a different field
Solr::deleteSingleDocument('unique_value', 'custom_field');

// Bulk delete by query or field criteria
Solr::bulkDeleteDocuments([
    'q' => 'description:document'
]);

// Bulk delete by specific field and array of values
Solr::bulkDeleteDocuments([
    'field' => 'custom_field',
    'values' => ['value1', 'value2', 'value3']
]);
```

### Overriding Default Configuration Values

[](#overriding-default-configuration-values)

When creating an instance of SolrClient, you can override the default values for base\_uri, default\_collection, and default\_params. This is useful if you need to use a separate Solr configuration for specific methods without affecting the global configuration.

```
use Ibraimv\SolrIntegration\SolrClient;

$customSolrClient = new SolrClient(null, [
    'base_uri' => 'http://custom-solr-server:8983/solr',
    'default_collection' => 'custom_collection',
    'default_params' => ['defType' => 'edismax', 'sort' => 'date desc']
]);

// Now you can use $customSolrClient with the specified configuration.
$customSolrClient->addDocument([
    'id' => '200',
    'title' => 'Custom Document',
    'description' => 'This document uses a custom Solr configuration.',
]);

```

### Methods

[](#methods)

- **addDocument(array $document)**: Add a single document to Solr.
- **bulkAddDocuments(array $documents)**: Add multiple documents at once.
- **deleteSingleDocument(string $value, string $field = 'id')**: Delete a document by a specific field.
- **bulkDeleteDocuments(array $criteria)**: Delete multiple documents based on query criteria or field values.
- **search(string $query, array $options = \[\])**: Perform a search query with customizable options.

### Configuration Options

[](#configuration-options)

- **base\_uri**: The base URL of the Solr server.
- **default\_collection**: The default Solr collection to use.
- **default\_params**: Default search parameters.

Exception Handling
------------------

[](#exception-handling)

All requests are wrapped in error handling. In case of failure, exceptions will be logged, and the error message can be found in the Laravel error logs.

License
-------

[](#license)

This package is open-source and licensed under the MIT License.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

556d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d2bedb0f8e4270d3992d658f8029510578514cc05a6979fc9a41a7eff8e2a918?d=identicon)[ibraimV](/maintainers/ibraimV)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ibraimv-laravel-solr-integration/health.svg)

```
[![Health](https://phpackages.com/badges/ibraimv-laravel-solr-integration/health.svg)](https://phpackages.com/packages/ibraimv-laravel-solr-integration)
```

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[grantholle/powerschool-api

A Laravel package to make interacting with PowerSchool less painful.

1715.6k1](/packages/grantholle-powerschool-api)

PHPackages © 2026

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