1. Installation - basemkhirat/elasticsearch GitHub Wiki
Laravel Installation
1) Install package using composer.
$ composer require basemkhirat/elasticsearch
2) Add package service provider (< laravel 5.5).
Basemkhirat\Elasticsearch\ElasticsearchServiceProvider::class
3) Add package alias (< laravel 5.5).
'ES' => Basemkhirat\Elasticsearch\Facades\ES::class
4) Publishing.
$ php artisan vendor:publish --provider="Basemkhirat\Elasticsearch\ElasticsearchServiceProvider"
Lumen Installation
1) Install package using composer.
$ composer require basemkhirat/elasticsearch
bootstrap/app.php
.
2) Add package service provider in $app->register(Basemkhirat\Elasticsearch\ElasticsearchServiceProvider::class);
vendor/basemkhirat/elasticsearch/src/config
to root folder alongside with app
directory.
3) Copy package config directory bootstrap/app.php
.
4) Making Lumen work with facades by uncommenting this line in $app->withFacades();
If you don't want to enable working with Lumen facades you can access the query builder using app("es")
.
app("es")->index("my_index")->type("my_type")->get();
# is similar to
ES::index("my_index")->type("my_type")->get();
Composer Installation
You can install package with any composer-based applications
1) Install package using composer.
$ composer require basemkhirat/elasticsearch
2) Creating a connection.
require "vendor/autoload.php";
use Basemkhirat\Elasticsearch\Connection;
$connection = Connection::create([
'servers' => [
[
"host" => '127.0.0.1',
"port" => 9200,
'user' => '',
'pass' => '',
'scheme' => 'http',
]
],
'index' => 'my_index',
]);
# access the query builder using created connection
$documents = $connection->search("hello")->get();