Download the PHP package cviebrock/laravel-elasticsearch-handlers without Composer

On this page you can find all versions of the php package cviebrock/laravel-elasticsearch-handlers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-elasticsearch-handlers

Laravel-Elasticsearch-Handlers

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

Build Status Total Downloads Latest Stable Version Latest Stable Version

Installation and Configuration

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

  2. Publish the configuration file. For Laravel 5:

    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:

  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.

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:

When you instantiate an Elasticsearch client with:

the package will create a base client (using the base elasticsearch.php configuration) then wrap it in the class defined by the clientClass setting, and inject the handlers array. So, in this case, an instance of Cviebrock\LaravelElasticsearchHandlers\Client is returned.

This class the bare minimum client wrapper. It doesn't do anything except pass-through all commands to the wrapped base Elasticsearch class.

Let's make it more useful ...

Creating Handlers

Pretend you only have one Elasticsearch instance running, but you need it to support indices for several of your Laravel application environments (e.g. "beta", "live", etc.)..

Instead of updating your code so that every time you index a document you make sure the right index name is specified, what if the client automatically prefixed the index name with the name of the current Laravel environment?

First, set up the package configuration like so:

Then create the Handler class (extending the BaseHandler class):

Now, every time you index a document using the default Elasticsearch connection, the current Laravel environment name will be prefixed to the index key of your data array.

This returns:

The index was prepended automatically, so your application will work across all environments without checks or changes.

Also, you can register more than one handler per connection, which means that the functionality is "chainable". E.g., prepend the environment to the index, and also add some default parameters to the body, etc..

Special boot Method

Handlers can also define a boot method with the following signature:

This is method is run when the handler is registered so it could be used, for example, to alter the behaviour of the client upon instantiation. The client is passed in as the only parameter.

Pre-Defined Handlers

The package ships with a few pre-defined handlers, all of which are in the Cviebrock\LaravelElasticsearchHandlers\Handlers namespace.

EnvironmentIndexPrefixHandler

Operates on the follow methods:

This is basically the same handler as used in the example above. It will take the current Laravel environment, mangles it a bit so it matches Elasticsearch's constraints for index names, and prepends it to the index key in the given document.

Bugs, Suggestions and Contributions

Please use Github for bugs, comments, suggestions.

  1. Fork the project.
  2. Create your bugfix/feature branch and write your (well-commented) code.
  3. Commit your changes (and your tests) and push to your branch.
  4. Create a new pull request against the master branch.

Copyright and License

Laravel-Elasticsearch-Handlers was written by Colin Viebrock and released under the MIT License. See the LICENSE file for details.

Copyright 2015 Colin Viebrock


All versions of laravel-elasticsearch-handlers with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version ~4|~5
cviebrock/laravel-elasticsearch Version ~0.9
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cviebrock/laravel-elasticsearch-handlers contains the following files

Loading the files please wait ....