PHPackages                             cviebrock/laravel-elasticsearch-handlers - 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. cviebrock/laravel-elasticsearch-handlers

ActiveLibrary[API Development](/categories/api)

cviebrock/laravel-elasticsearch-handlers
========================================

Further easiness when using Elasticsearch with Laravel

0.9.0(10y ago)22292MITPHPPHP &gt;=5.4.0

Since Jun 9Pushed 10y ago1 watchersCompare

[ Source](https://github.com/cviebrock/laravel-elasticsearch-handlers)[ Packagist](https://packagist.org/packages/cviebrock/laravel-elasticsearch-handlers)[ RSS](/packages/cviebrock-laravel-elasticsearch-handlers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Laravel-Elasticsearch-Handlers
==============================

[](#laravel-elasticsearch-handlers)

An even easier way to use the official Elastic Search client in your Laravel applications.

[![Build Status](https://camo.githubusercontent.com/9092b6fcc269e09183f19150af2aee56220b8b6686ecb55c42b08acaf5aa8067/68747470733a2f2f7472617669732d63692e6f72672f6376696562726f636b2f6c61726176656c2d656c61737469637365617263682d68616e646c6572732e737667)](https://travis-ci.org/cviebrock/laravel-elasticsearch-handlers)[![Total Downloads](https://camo.githubusercontent.com/4f197d47b22bcf975e97e89c0d030aa613e84c021b02597002e21cb6854833d8/68747470733a2f2f706f7365722e707567782e6f72672f6376696562726f636b2f6c61726176656c2d656c61737469637365617263682d68616e646c6572732f646f776e6c6f6164732e706e67)](https://packagist.org/packages/cviebrock/laravel-elasticsearch-handlers)[![Latest Stable Version](https://camo.githubusercontent.com/78f77a29e941dabc700f4f811e7ecfa5d29c71e36c3de3d41768f1f624b9692b/68747470733a2f2f706f7365722e707567782e6f72672f6376696562726f636b2f6c61726176656c2d656c61737469637365617263682d68616e646c6572732f762f737461626c652e706e67)](https://packagist.org/packages/cviebrock/laravel-elasticsearch-handlers)[![Latest Stable Version](https://camo.githubusercontent.com/d3835d60b51de1f6a0db009f663c2910be47b89936887d5b3b071b45a5d13d4b/68747470733a2f2f706f7365722e707567782e6f72672f6376696562726f636b2f6c61726176656c2d656c61737469637365617263682d68616e646c6572732f762f756e737461626c652e706e67)](https://packagist.org/packages/cviebrock/laravel-elasticsearch-handlers)

- [Installation and Configuration](#installation)
- [Usage](#usage)
- [Creating Handlers](#creating-handlers)
    - [Special `boot` Method](#special-boot-method)
- [Pre-Defined Handlers](#pre-defined-handlers)
    - [EnvironmentIndexPrefixHandler](#environment-index-prefix-handler)
- [Bugs, Suggestions and Contributions](#bugs)
- [Copyright and License](#copyright)

Installation and Configuration
------------------------------

[](#installation-and-configuration)

1. Install the `cviebrock/laravel-elasticsearch-handlers` package via composer:

    ```
    $ composer require cviebrock/laravel-elasticsearch-handlers
    ```
2. Publish the configuration file. For Laravel 5:

    ```
    php artisan vendor:publish cviebrock/laravel-elasticsearch-handlers
    ```

    In order to make this package also work with Laravel 4, we can't do the standard configuration publishing like most Laravel 4 packages do. You will need to simply copy the configuration file into your application's configuration folder:

    ```
    cp vendor/cviebrock/laravel-elasticsearch-handlers/config/elasticsearch-handlers.php app/config/
    ```
3. Add the service provider (`config/app.php` for Laravel 5 or `app/config/app.php` for Laravel 4). The service provider needs to come after the `LaravelElasticsearch` provider, since we "hijack" the Manager class from that package and use our own.

    ```
    'providers' => array(
        ...
        'Cviebrock\LaravelElasticSearch\ServiceProvider',
        'Cviebrock\LaravelElasticSearchHandlers\ServiceProvider',
    )
    ```

Usage
-----

[](#usage)

This package extends the `laravel-elasticsearch` package by returning a "decorated" Elasticsearch client class, instead of the default PHP client. You can configure how the client is decorated on a per-connection basis.

Take the following example `elasticsearch-handlers.php` configuration:

```
