From 9c19d34e9e12480b3b6a674efce6a468e92e00f0 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Tue, 20 Sep 2016 11:27:09 +0300 Subject: [PATCH 01/42] delete unnecessary folders --- public/.gitkeep | 0 src/config/.gitkeep | 0 src/controllers/.gitkeep | 0 src/lang/.gitkeep | 0 src/migrations/.gitkeep | 0 src/views/.gitkeep | 0 6 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 public/.gitkeep delete mode 100644 src/config/.gitkeep delete mode 100644 src/controllers/.gitkeep delete mode 100644 src/lang/.gitkeep delete mode 100644 src/migrations/.gitkeep delete mode 100644 src/views/.gitkeep diff --git a/public/.gitkeep b/public/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/config/.gitkeep b/src/config/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/controllers/.gitkeep b/src/controllers/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/lang/.gitkeep b/src/lang/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/migrations/.gitkeep b/src/migrations/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/views/.gitkeep b/src/views/.gitkeep deleted file mode 100644 index e69de29..0000000 From 0e003014ab76b7eaefe80a7a533ab25a48e1d661 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Tue, 20 Sep 2016 11:48:57 +0300 Subject: [PATCH 02/42] Add laravel/framework for require package because of AliasLoader and storage_path functions are inside laravel framework not in illuminate/support package. We do not need minimum-stability packages. --- composer.json | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index 08ce92a..2b2667c 100644 --- a/composer.json +++ b/composer.json @@ -1,28 +1,20 @@ { - "name": "shift31/laravel-elasticsearch", - "description": "A Laravel Service Provider for the Elasticsearch API client", - "authors": [ - { - "name": "Shift 31 Consulting", - "email": "code@shift31.com" - } - ], - "require": { - "php": ">=5.4.0", - "illuminate/support": "~4|~5", - "elasticsearch/elasticsearch": "~2.0" - }, - "autoload": { - "classmap": [ - "src/migrations" - ], - "psr-0": { - "Shift31\\LaravelElasticsearch": "src/" - } - }, - "minimum-stability": "dev", - "prefer-stable": true, - "require-dev": { - "laravel/framework": "^5.2" + "name": "shift31/laravel-elasticsearch", + "description": "A Laravel Service Provider for the Elasticsearch API client", + "authors": [ + { + "name": "Shift 31 Consulting", + "email": "code@shift31.com" } + ], + "require": { + "php": ">=5.4.0", + "laravel/framework": "~4|~5", + "elasticsearch/elasticsearch": "~2.0" + }, + "autoload": { + "psr-0": { + "Shift31\\LaravelElasticsearch": "src/" + } + } } From 4211fbe8aa93df6efe27dc9dec967a3ab6ab4904 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Tue, 20 Sep 2016 12:55:16 +0300 Subject: [PATCH 03/42] add elasticsearch default config file --- src/config/elasticsearch.php | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/config/elasticsearch.php diff --git a/src/config/elasticsearch.php b/src/config/elasticsearch.php new file mode 100644 index 0000000..a371e85 --- /dev/null +++ b/src/config/elasticsearch.php @@ -0,0 +1,6 @@ + ['localhost:9200'], + 'logPath' => storage_path('logs/elastic-search.log'), +]; \ No newline at end of file From 727e3eedca7dbdfc59902ddb0c75c891309c6248 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Tue, 20 Sep 2016 13:30:55 +0300 Subject: [PATCH 04/42] Update Service Providers for publish elastic search config file. --- README.md | 16 +++++++-- .../ElasticsearchServiceProvider.php | 21 ++++++------ .../LaravelElasticsearchServiceProvider.php | 33 ++++++++++--------- 3 files changed, 41 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 35eb4b7..bac874d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,18 @@ Usage ----- 1. Run `composer require shift31/laravel-elasticsearch:~2.0` -2. Create app/config/elasticsearch.php, modifying the following contents accordingly: +2. Publish config file + +Laravel 4x +``` +$ php artisan config:publish shift31/laravel-elasticsearch +``` +Laravel 5x +``` +$ php artisan vendor:publish --provider="Shift31\LaravelElasticsearch\ElasticsearchServiceProvider" --tag=config +``` + +Manually: Create app/config/elasticsearch.php, modifying the following contents accordingly: ```php 'path/to/your/elasticsearch/log', ); ``` - -The keys of this array should be named according the parameters supported by Elasticsearch\Client. +Note: The keys of this array should be named according the parameters supported by Elasticsearch\Client. 3. In the `'providers'` array in app/config/app.php, if you are using Laravel 4.x, add `'Shift31\LaravelElasticsearch\LaravelElasticsearchServiceProvider'`. diff --git a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php index 36fccba..a02db9a 100644 --- a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php @@ -13,25 +13,26 @@ */ class ElasticsearchServiceProvider extends ServiceProvider { - /** + /** * Register the service provider. * * @return void */ public function register() { - $this->app->singleton('Elasticsearch\Client', function () { + // publish config file + $this->publishes([ + __DIR__ . '/../../config/elasticsearch.php' => config_path('elasticsearch.php') + ], 'config'); - $connParams = []; - $connParams['hosts'] = ['localhost:9200']; - $connParams['logPath'] = storage_path() . '/logs/elasticsearch-' . php_sapi_name() . '.log'; + // merge default config variables + $this->mergeConfigFrom(__DIR__ . '/../../config/elasticsearch.php', 'elasticsearch'); - // merge settings from app/config/elasticsearch.php - $params = array_merge($connParams, $this->app['config']->get('elasticsearch', [])); - - $logger = ClientBuilder::defaultLogger($params['logPath']); + $this->app->singleton('Elasticsearch\Client', function () { + $config = $this->app->config->get('elasticsearch'); + $logger = ClientBuilder::defaultLogger($config['logPath']); - return ClientBuilder::create()->setHosts($params['hosts'])->setLogger($logger)->build(); + return ClientBuilder::crecdate()->setHosts($config['hosts'])->setLogger($logger)->build(); }); diff --git a/src/Shift31/LaravelElasticsearch/LaravelElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/LaravelElasticsearchServiceProvider.php index 041490c..1e6742f 100644 --- a/src/Shift31/LaravelElasticsearch/LaravelElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/LaravelElasticsearchServiceProvider.php @@ -11,7 +11,8 @@ * * @package Shift31\LaravelElasticsearch */ -class LaravelElasticsearchServiceProvider extends ServiceProvider { +class LaravelElasticsearchServiceProvider extends ServiceProvider +{ /** * Indicates if loading of the provider is deferred. @@ -27,7 +28,7 @@ class LaravelElasticsearchServiceProvider extends ServiceProvider { */ public function boot() { - $this->package('shift31/laravel-elasticsearch'); + $this->package('shift31/laravel-elasticsearch', null, __DIR__ . '/../..'); } /** @@ -37,29 +38,29 @@ public function boot() */ public function register() { - $this->app->singleton('elasticsearch', function() - { + // set elasticsearch config + $this->setConfig(); + $this->app->singleton('elasticsearch', function () { + $config = $this->app->config->get('elasticsearch'); + $logger = ClientBuilder::defaultLogger($config['logPath']); - $connParams = []; - $connParams['hosts'] = array('localhost:9200'); - $connParams['logPath'] = storage_path() . '/logs/elasticsearch-' . php_sapi_name() . '.log'; - - // merge settings from app/config/elasticsearch.php - $params = array_merge($connParams, $this->app['config']->get('elasticsearch')); - - $logger = ClientBuilder::defaultLogger($params['logPath']); - - return ClientBuilder::create()->setHosts($params['hosts'])->setLogger($logger)->build(); + return ClientBuilder::create()->setHosts($config['hosts'])->setLogger($logger)->build(); }); // Shortcut so developers don't need to add an Alias in app/config/app.php - $this->app->booting(function() - { + $this->app->booting(function () { $loader = AliasLoader::getInstance(); $loader->alias('Es', 'Shift31\LaravelElasticsearch\Facades\Es'); }); } + private function setConfig() + { + $packageConfigPath = __DIR__ . '/../../config/elasticsearch.php'; + $config = $this->app['config']->get('elasticsearch', []); + $this->app['config']->set('elasticsearch', array_merge(require $packageConfigPath, $config)); + } + /** * Get the services provided by the provider. * From 540952db02fda2fb8428e6864a4c6a768d334d78 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Tue, 14 Feb 2017 12:04:02 +0200 Subject: [PATCH 05/42] Update code with psr-2 standards --- phpcs.xml | 6 ++++++ .../ElasticsearchServiceProvider.php | 3 +-- src/Shift31/LaravelElasticsearch/Facades/Es.php | 16 +++++++++++----- src/config/elasticsearch.php | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 phpcs.xml diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..9ae78a5 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,6 @@ + + + + ./src + ./tests + \ No newline at end of file diff --git a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php index a02db9a..f8aa609 100644 --- a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php @@ -32,8 +32,7 @@ public function register() $config = $this->app->config->get('elasticsearch'); $logger = ClientBuilder::defaultLogger($config['logPath']); - return ClientBuilder::crecdate()->setHosts($config['hosts'])->setLogger($logger)->build(); - + return ClientBuilder::create()->setHosts($config['hosts'])->setLogger($logger)->build(); }); $this->app->alias('Elasticsearch\Client', 'elasticsearch'); diff --git a/src/Shift31/LaravelElasticsearch/Facades/Es.php b/src/Shift31/LaravelElasticsearch/Facades/Es.php index bee2de5..7914610 100644 --- a/src/Shift31/LaravelElasticsearch/Facades/Es.php +++ b/src/Shift31/LaravelElasticsearch/Facades/Es.php @@ -2,8 +2,14 @@ use Illuminate\Support\Facades\Facade; - -class Es extends Facade { - - protected static function getFacadeAccessor() { return 'elasticsearch'; } -} \ No newline at end of file +/** + * @see \Elasticsearch\ClientBuilder + */ +class Es extends Facade +{ + + protected static function getFacadeAccessor() + { + return 'elasticsearch'; + } +} diff --git a/src/config/elasticsearch.php b/src/config/elasticsearch.php index a371e85..677fdc2 100644 --- a/src/config/elasticsearch.php +++ b/src/config/elasticsearch.php @@ -3,4 +3,4 @@ return [ 'hosts' => ['localhost:9200'], 'logPath' => storage_path('logs/elastic-search.log'), -]; \ No newline at end of file +]; From 4cb9f345ca0d8c11717f545ea89d1d6728523bd1 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Tue, 14 Feb 2017 12:04:29 +0200 Subject: [PATCH 06/42] Update travis-ci build. --- .travis.yml | 16 +++++++++++----- composer.json | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0a1c1cb..cd11c3f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,18 @@ language: php -php: - - 5.3 +php: - 5.4 - 5.5 + - 5.6 before_script: - - curl -s http://getcomposer.org/installer | php - - php composer.phar install --dev + - travis_retry composer self-update + - travis_retry composer update --prefer-dist --no-interaction -script: phpunit \ No newline at end of file +script: + - mkdir -p build/logs + - protected/vendor/bin/phpcs + - protected/vendor/bin/phpunit + +after_script: + - protected/vendor/bin/coveralls -v \ No newline at end of file diff --git a/composer.json b/composer.json index 2b2667c..39ff404 100644 --- a/composer.json +++ b/composer.json @@ -12,9 +12,24 @@ "laravel/framework": "~4|~5", "elasticsearch/elasticsearch": "~2.0" }, + "require-dev": { + "squizlabs/php_codesniffer": "^2.8", + "phpunit/phpunit": "^5.7" + }, "autoload": { "psr-0": { "Shift31\\LaravelElasticsearch": "src/" } + }, + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "scripts": { + "test": [ + "vendor/bin/phpcs", + "vendor/bin/phpunit" + ] } } From 28f471780c2254f895b5450230fb00425dd0a9ed Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Tue, 14 Feb 2017 12:04:40 +0200 Subject: [PATCH 07/42] Add licence. --- LICENCE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENCE diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..b7e3ae2 --- /dev/null +++ b/LICENCE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Shift 31 Consulting + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file From 46223acfdca8e46087538fc2c41487f08067cc2a Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Tue, 14 Feb 2017 12:05:10 +0200 Subject: [PATCH 08/42] Add contributing information. --- CONTRIBUTING.md | 17 +++++++++++++++++ README.md | 4 ++++ 2 files changed, 21 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..fce0e35 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,17 @@ +# Contributing + +Before you contribute code to laravel-elasticsearch, please make sure it conforms PHPCS coding standard and unit tests +still pass. + +## How to +Fork, then clone the repo: + + git clone git@github.com:your-username/laravel-elasticsearch.git + +Make sure the tests pass: + + composer test + +Make your change. Add tests for your change. Make the tests pass + +Push to your fork and [submit a pull request][pr]. \ No newline at end of file diff --git a/README.md b/README.md index bac874d..4eeb741 100644 --- a/README.md +++ b/README.md @@ -68,3 +68,7 @@ If you return an empty array in the config file: `'hosts'` defaults to localhost:9200 `'logPath'` defaults to `storage_path() . '/logs/elasticsearch.log'` + +Contributing +--------------------- +Please see [CONTRIBUTING.md](CONTRIBUTING.md). \ No newline at end of file From 00845c37e5983c07d908342baf6fa91f91db9bdb Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Tue, 14 Feb 2017 12:05:43 +0200 Subject: [PATCH 09/42] Delete unnecessary docker.yml file. --- docker-compose.yml | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 05985ca..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,5 +0,0 @@ -elasticsearch: - image: elasticsearch - ports: - - "9300:9300" - - "9200:9200" \ No newline at end of file From fe2d315f0d0a8ffcf9167338c7c7995d1c9f478a Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Tue, 14 Feb 2017 12:12:16 +0200 Subject: [PATCH 10/42] Add repository badges in to readme file. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 4eeb741..89c287c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ Elasticsearch for Laravel ========================= +[![Latest Stable Version](https://poser.pugx.org/shift31/laravel-elasticsearch/v/stable)](https://packagist.org/packages/shift31/laravel-elasticsearch) +[![Total Downloads](https://poser.pugx.org/shift31/laravel-elasticsearch/downloads)](https://packagist.org/packages/shift31/laravel-elasticsearch) +[![Build Status](https://travis-ci.org/shift31/laravel-elasticsearch.svg?branch=master)](https://travis-ci.org/shift31/laravel-elasticsearch) +[![Coverage Status](https://coveralls.io/repos/github/shift31/laravel-elasticsearch/badge.svg?branch=master)](https://coveralls.io/github/shift31/laravel-elasticsearch?branch=master) +[![License](https://poser.pugx.org/shift31/laravel-elasticsearch/license)](https://packagist.org/packages/shift31/laravel-elasticsearch) + This is a Laravel (4+) Service Provider for the official Elasticsearch low-level client: http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/index.html From ab34e45c43356dba8bca1de9542f16b883bf53b8 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Thu, 16 Feb 2017 08:53:51 +0200 Subject: [PATCH 11/42] Add new version matrix to readme.md --- README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 89c287c..ef10730 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ This is a Laravel (4+) Service Provider for the official Elasticsearch low-level http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/index.html -Version Matrix --------------- +Old Version Matrix +------------------ Since there are breaking changes in Elasticsearch 1.0, your version of Elasticsearch must match the version of this library, which matches the version of the Elasticsearch low-level client. If you are using a version older than 1.0, you must install the `0.4` laravel-elasticsearch branch. Otherwise, use the `1.0` branch. @@ -22,6 +22,20 @@ The master branch will always track the latest version. | >= 1.0 | 1.0, 2.0 | | <= 0.90.* | 0.4 | +New Version Matrix (under development!) +------------------ +| Elasticsearch Version | Laravel | laravel-elasticsearch branch | +| --------------------- |---------| ---------------------------- | +| 5.0 | 4.2 | 4.5 | +| 2.0 | 4.2 | 4.2 | +| 1.0 | 4.2 | 4.1 | +| <= 0.90.* | 4.2 | 4.0 | +| 5.0 | 5.x | 5.5 | +| 2.0 | 5.2 | 5.2 | +| 1.0 | 5.2 | 5.1 | +| <= 0.90.* | 5.2 | 5.0 | + + **Support for v1.1.x of the Elasticsearch client has been added in v1.1 of laravel-elasticsearch.** We'll try to be consistent with this convention going forward. Usage From 7405a2946cac3f9eed37c666444ca814afc395d2 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Thu, 16 Feb 2017 08:54:52 +0200 Subject: [PATCH 12/42] Update composer.json for 4.0 version --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 39ff404..ba40b07 100644 --- a/composer.json +++ b/composer.json @@ -8,9 +8,9 @@ } ], "require": { - "php": ">=5.4.0", - "laravel/framework": "~4|~5", - "elasticsearch/elasticsearch": "~2.0" + "php": ">=5.4.0 <=7.0.0", + "laravel/framework": "~4.2.0", + "elasticsearch/elasticsearch": "~0.4" }, "require-dev": { "squizlabs/php_codesniffer": "^2.8", @@ -23,7 +23,7 @@ }, "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "4.0.x-dev" } }, "scripts": { From d1ab44b79320584892e58e276baf1d84c2316c84 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Thu, 16 Feb 2017 09:06:45 +0200 Subject: [PATCH 13/42] Update readme file for new version matrix and information included only for laravel 4.2. --- README.md | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index ef10730..b2feb94 100644 --- a/README.md +++ b/README.md @@ -10,19 +10,24 @@ This is a Laravel (4+) Service Provider for the official Elasticsearch low-level http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/index.html -Old Version Matrix +Version Matrix ------------------ -Since there are breaking changes in Elasticsearch 1.0, your version of Elasticsearch must match the version of this library, which matches the version of the Elasticsearch low-level client. -If you are using a version older than 1.0, you must install the `0.4` laravel-elasticsearch branch. Otherwise, use the `1.0` branch. +Since there are breaking changes in Elasticsearch 1.0, your version of Elasticsearch must match the version of this +library, which matches the version of the Elasticsearch low-level client. If you are using a version older than 1.0, you + must install the `0.4` laravel-elasticsearch branch. Otherwise, use the `1.0` branch. The master branch will always track the latest version. +Old +--- | Elasticsearch Version | laravel-elasticsearch branch | | --------------------- | ---------------------------- | | >= 1.0 | 1.0, 2.0 | | <= 0.90.* | 0.4 | -New Version Matrix (under development!) +Attention: Until we launch new versions please keep using old versions and don't use dev-master branch! + +New (Under development!) ------------------ | Elasticsearch Version | Laravel | laravel-elasticsearch branch | | --------------------- |---------| ---------------------------- | @@ -35,25 +40,19 @@ New Version Matrix (under development!) | 1.0 | 5.2 | 5.1 | | <= 0.90.* | 5.2 | 5.0 | - -**Support for v1.1.x of the Elasticsearch client has been added in v1.1 of laravel-elasticsearch.** We'll try to be consistent with this convention going forward. - Usage ----- -1. Run `composer require shift31/laravel-elasticsearch:~2.0` +1. Run `composer require shift31/laravel-elasticsearch:~4.0.0` 2. Publish config file -Laravel 4x +Laravel artisan command ``` $ php artisan config:publish shift31/laravel-elasticsearch ``` -Laravel 5x -``` -$ php artisan vendor:publish --provider="Shift31\LaravelElasticsearch\ElasticsearchServiceProvider" --tag=config -``` -Manually: Create app/config/elasticsearch.php, modifying the following contents accordingly: +Manually: Create [app/config/elasticsearch.php](src/config/elasticsearch.php), modifying the following contents +accordingly: ```php Date: Thu, 16 Feb 2017 09:12:11 +0200 Subject: [PATCH 14/42] Update readme file with package version --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b2feb94..899fbbc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Elasticsearch for Laravel -========================= +Laravel Elasticsearch Service Provider (v4.0.x) +================================================ [![Latest Stable Version](https://poser.pugx.org/shift31/laravel-elasticsearch/v/stable)](https://packagist.org/packages/shift31/laravel-elasticsearch) [![Total Downloads](https://poser.pugx.org/shift31/laravel-elasticsearch/downloads)](https://packagist.org/packages/shift31/laravel-elasticsearch) [![Build Status](https://travis-ci.org/shift31/laravel-elasticsearch.svg?branch=master)](https://travis-ci.org/shift31/laravel-elasticsearch) From 17403fb49b508d6d33b1f00292b814014b35b641 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Sun, 26 Feb 2017 00:02:35 +0200 Subject: [PATCH 15/42] Add logLevel option in elasticsearch config file. --- src/config/elasticsearch.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/config/elasticsearch.php b/src/config/elasticsearch.php index 677fdc2..5d5bf32 100644 --- a/src/config/elasticsearch.php +++ b/src/config/elasticsearch.php @@ -3,4 +3,5 @@ return [ 'hosts' => ['localhost:9200'], 'logPath' => storage_path('logs/elastic-search.log'), + 'logLevel' => 400, ]; From 1f97f965bff5e065bf49a5d4c443adcab10137b1 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Sun, 26 Feb 2017 00:04:05 +0200 Subject: [PATCH 16/42] Update register method for elastic search 0.4 version. --- .../ElasticsearchServiceProvider.php | 55 ++++++-------- .../LaravelElasticsearch/Facades/Es.php | 2 +- .../LaravelElasticsearchServiceProvider.php | 73 ------------------- 3 files changed, 24 insertions(+), 106 deletions(-) delete mode 100644 src/Shift31/LaravelElasticsearch/LaravelElasticsearchServiceProvider.php diff --git a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php index f8aa609..bfabdd2 100644 --- a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php @@ -1,43 +1,31 @@ -publishes([ - __DIR__ . '/../../config/elasticsearch.php' => config_path('elasticsearch.php') - ], 'config'); - - // merge default config variables - $this->mergeConfigFrom(__DIR__ . '/../../config/elasticsearch.php', 'elasticsearch'); + $this->package('shift31/laravel-elasticsearch'); + } - $this->app->singleton('Elasticsearch\Client', function () { - $config = $this->app->config->get('elasticsearch'); - $logger = ClientBuilder::defaultLogger($config['logPath']); + /** + * @inheritdoc + */ + public function register() + { + $this->app->singleton('elasticsearch', function () { + $customConfig = $this->app->config->get('elasticsearch'); + $defaultConfig = $this->loadDefaultConfig(); - return ClientBuilder::create()->setHosts($config['hosts'])->setLogger($logger)->build(); + return new Client(array_merge($defaultConfig, $customConfig)); }); - - $this->app->alias('Elasticsearch\Client', 'elasticsearch'); - - // Shortcut so developers don't need to add an Alias in app/config/app.php $this->app->booting(function () { $loader = AliasLoader::getInstance(); $loader->alias('Es', 'Shift31\LaravelElasticsearch\Facades\Es'); @@ -45,12 +33,15 @@ public function register() } /** - * Get the services provided by the provider. - * - * @return array + * @inheritdoc */ public function provides() { - return ['elasticsearch', 'Elasticsearch\Client']; + return ['elasticsearch']; + } + + private function loadDefaultConfig() + { + return $this->app->files->getRequire(realpath(__DIR__ . '/../../config/elasticsearch.php')); } } diff --git a/src/Shift31/LaravelElasticsearch/Facades/Es.php b/src/Shift31/LaravelElasticsearch/Facades/Es.php index 7914610..3d60708 100644 --- a/src/Shift31/LaravelElasticsearch/Facades/Es.php +++ b/src/Shift31/LaravelElasticsearch/Facades/Es.php @@ -3,7 +3,7 @@ use Illuminate\Support\Facades\Facade; /** - * @see \Elasticsearch\ClientBuilder + * @see \Elasticsearch\Client */ class Es extends Facade { diff --git a/src/Shift31/LaravelElasticsearch/LaravelElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/LaravelElasticsearchServiceProvider.php deleted file mode 100644 index 1e6742f..0000000 --- a/src/Shift31/LaravelElasticsearch/LaravelElasticsearchServiceProvider.php +++ /dev/null @@ -1,73 +0,0 @@ -package('shift31/laravel-elasticsearch', null, __DIR__ . '/../..'); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - // set elasticsearch config - $this->setConfig(); - $this->app->singleton('elasticsearch', function () { - $config = $this->app->config->get('elasticsearch'); - $logger = ClientBuilder::defaultLogger($config['logPath']); - - return ClientBuilder::create()->setHosts($config['hosts'])->setLogger($logger)->build(); - }); - - // Shortcut so developers don't need to add an Alias in app/config/app.php - $this->app->booting(function () { - $loader = AliasLoader::getInstance(); - $loader->alias('Es', 'Shift31\LaravelElasticsearch\Facades\Es'); - }); - } - - private function setConfig() - { - $packageConfigPath = __DIR__ . '/../../config/elasticsearch.php'; - $config = $this->app['config']->get('elasticsearch', []); - $this->app['config']->set('elasticsearch', array_merge(require $packageConfigPath, $config)); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return array('elasticsearch'); - } -} From bed7b4b37634226fd0075e4afd44a26ccbcd4bfc Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Sun, 26 Feb 2017 00:05:07 +0200 Subject: [PATCH 17/42] Add Mockery and set autoload-dev for tests. --- composer.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ba40b07..63932ce 100644 --- a/composer.json +++ b/composer.json @@ -14,13 +14,19 @@ }, "require-dev": { "squizlabs/php_codesniffer": "^2.8", - "phpunit/phpunit": "^5.7" + "phpunit/phpunit": "^5.7", + "mockery/mockery": "^0.9.8" }, "autoload": { "psr-0": { "Shift31\\LaravelElasticsearch": "src/" } }, + "autoload-dev": { + "psr-4": { + "Shift31\\LaravelElasticsearch\\Tests\\": "tests/" + } + }, "extra": { "branch-alias": { "dev-master": "4.0.x-dev" From d83f5e5da7c3707583059b31b7cbaea1e649d486 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Sun, 26 Feb 2017 00:05:32 +0200 Subject: [PATCH 18/42] Remove tests folder from code sniffer --- phpcs.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index 9ae78a5..c7ea2bb 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -2,5 +2,4 @@ ./src - ./tests \ No newline at end of file From a3f20fe1dc9d9a07052a727e7f54f3f5d0a771ba Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Sun, 26 Feb 2017 00:05:56 +0200 Subject: [PATCH 19/42] Update test suite name to unit. --- phpunit.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index e89ac6d..59d3568 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -8,11 +8,10 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" -> + syntaxCheck="false"> - - ./tests/ + + ./tests/Unit \ No newline at end of file From bb1fdef19540da6f373f990d00d61eb911adfabe Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Sun, 26 Feb 2017 00:12:34 +0200 Subject: [PATCH 20/42] Add unit tests for elastic search service provider and facade. --- tests/.gitkeep | 0 tests/TestCase.php | 14 +++ .../ElasticsearchServiceProviderUnitTest.php | 91 +++++++++++++++++++ tests/Unit/EsUnitTest.php | 21 +++++ 4 files changed, 126 insertions(+) delete mode 100644 tests/.gitkeep create mode 100644 tests/TestCase.php create mode 100644 tests/Unit/ElasticsearchServiceProviderUnitTest.php create mode 100644 tests/Unit/EsUnitTest.php diff --git a/tests/.gitkeep b/tests/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..2d83285 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,14 @@ +assertEquals(['elasticsearch'], $provider->provides()); + } + + public function test_boot_method_to_set_config_file() + { + $configPath = realpath($this->getSourcePath('config')); + $filesMock = Mockery::mock(Filesystem::class, function (MockInterface $m) use ($configPath) { + $m->shouldReceive('isDirectory')->with($configPath)->once()->andReturn(true); + $m->shouldReceive('isDirectory')->withAnyArgs()->times(3)->andReturn(false); + }); + $configMock = Mockery::mock(Repository::class, function (MockInterface $m) use ($configPath) { + $m->shouldReceive('package') + ->with('shift31/laravel-elasticsearch', $configPath, 'laravel-elasticsearch') + ->once() + ->andReturnSelf(); + }); + $application = Mockery::mock(Application::class, function (MockInterface $m) use ($configMock, $filesMock) { + $m->shouldReceive('offsetGet')->with('config')->once()->andReturn($configMock); + $m->shouldReceive('offsetGet')->with('files')->times(4)->andReturn($filesMock); + $m->shouldReceive('offsetGet')->with('path')->once()->andReturn($this->getSourcePath()); + }); + $provider = new ElasticsearchServiceProvider($application); + $this->assertNull($provider->boot()); + } + + public function test_register_method_to_set_singleton_elastic_search_client() + { + $configPath = $this->getSourcePath('config/elasticsearch.php'); + $configMock = Mockery::mock(Repository::class, function (MockInterface $m) { + $m->shouldReceive('get')->with('elasticsearch')->andReturn([]); + }); + $filesMock = Mockery::mock(Filesystem::class, function (MockInterface $m) use ($configPath) { + $m->shouldReceive('getRequire') + ->with($configPath) + ->once()->andReturn([]); + }); + $application = Mockery::mock(Application::class, function (MockInterface $m) use ($configMock, $filesMock) { + $m->shouldReceive('booting')->once()->andReturnSelf(); + $m->shouldReceive('offsetGet')->with('config')->andReturn($configMock); + $m->shouldReceive('offsetGet')->with('files')->andReturn($filesMock); + $m->shouldReceive('singleton')->with('elasticsearch', + Mockery::on(function ($closure) { + $this->assertInstanceOf(Client::class, $closure()); + + return true; + }))->once()->andReturnSelf(); + }); + $provider = new ElasticsearchServiceProvider($application); + $this->assertNull($provider->register()); + } + + public function test_register_method_to_set_elastic_search_facade() + { + $application = Mockery::mock(Application::class, function (MockInterface $m) { + $m->shouldReceive('singleton')->once()->andReturnSelf(); + $m->shouldReceive('booting')->with(Mockery::on(function ($closure) { + $closure(); + $loader = AliasLoader::getInstance(); + $this->assertArrayHasKey('Es', $loader->getAliases()); + $this->assertEquals('Shift31\LaravelElasticsearch\Facades\Es', $loader->getAliases()['Es']); + + return true; + }))->andReturnSelf(); + }); + $provider = new ElasticsearchServiceProvider($application); + $this->assertNull($provider->register()); + } + + protected function getSourcePath($path = '') + { + return realpath(__DIR__ . '/../../src/' . $path); + } +} diff --git a/tests/Unit/EsUnitTest.php b/tests/Unit/EsUnitTest.php new file mode 100644 index 0000000..2c1d814 --- /dev/null +++ b/tests/Unit/EsUnitTest.php @@ -0,0 +1,21 @@ +getMethod('getFacadeAccessor'); + $method->setAccessible(true); + $provider = new ElasticsearchServiceProvider(Mockery::mock(Application::class)); + $this->assertEquals($provider->provides(), (array)$method->invoke(new Es())); + } +} \ No newline at end of file From 2040b0c04233e84cb9ecc4f09287d18c3de82192 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Sun, 26 Feb 2017 00:14:03 +0200 Subject: [PATCH 21/42] Update new version matrix list. --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 899fbbc..a87306e 100644 --- a/README.md +++ b/README.md @@ -31,14 +31,14 @@ New (Under development!) ------------------ | Elasticsearch Version | Laravel | laravel-elasticsearch branch | | --------------------- |---------| ---------------------------- | -| 5.0 | 4.2 | 4.5 | -| 2.0 | 4.2 | 4.2 | -| 1.0 | 4.2 | 4.1 | | <= 0.90.* | 4.2 | 4.0 | -| 5.0 | 5.x | 5.5 | -| 2.0 | 5.2 | 5.2 | -| 1.0 | 5.2 | 5.1 | +| 1.0 | 4.2 | 4.1 | +| 2.0 | 4.2 | 4.2 | +| 5.0 | 4.2 | 4.5 | | <= 0.90.* | 5.2 | 5.0 | +| 1.0 | 5.2 | 5.1 | +| 2.0 | 5.2 | 5.2 | +| 5.0 | 5.x | 5.5 | Usage ----- From f7a5fcb2403bc70d03867c88dd38250c832d7b93 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Sun, 26 Feb 2017 10:49:53 +0200 Subject: [PATCH 22/42] Update phpunit version to be compatible with PHP 5.4 version. Add php-coveralls package for coverage reports. --- .gitignore | 7 ++----- composer.json | 5 +++-- phpunit.xml | 8 ++++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 9fd998d..81361bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ +/build /vendor -composer.phar -composer.lock -.DS_Store -.idea -atlassian-ide-plugin.xml \ No newline at end of file +composer.lock \ No newline at end of file diff --git a/composer.json b/composer.json index 63932ce..ee89884 100644 --- a/composer.json +++ b/composer.json @@ -14,8 +14,9 @@ }, "require-dev": { "squizlabs/php_codesniffer": "^2.8", - "phpunit/phpunit": "^5.7", - "mockery/mockery": "^0.9.8" + "phpunit/phpunit": "^4.8", + "mockery/mockery": "^0.9.8", + "satooshi/php-coveralls": "^1.0" }, "autoload": { "psr-0": { diff --git a/phpunit.xml b/phpunit.xml index 59d3568..699ae2a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -14,4 +14,12 @@ ./tests/Unit + + + ./vendor/* + + + + + \ No newline at end of file From e2cf6d1bef39d4844bfd9bc3b271820478a282e9 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Sun, 26 Feb 2017 10:50:36 +0200 Subject: [PATCH 23/42] Update travis build file and correct bin paths --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd11c3f..bfedea1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ before_script: script: - mkdir -p build/logs - - protected/vendor/bin/phpcs - - protected/vendor/bin/phpunit + - vendor/bin/phpcs + - vendor/bin/phpunit after_script: - - protected/vendor/bin/coveralls -v \ No newline at end of file + - vendor/bin/coveralls -v \ No newline at end of file From 8d7bfd9144b2ff6444f42d7c9bfd03391e012361 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 11:51:21 +0200 Subject: [PATCH 24/42] Update mockery mock class names for php 54. --- .../ElasticsearchServiceProviderUnitTest.php | 31 +++++++++---------- tests/Unit/EsUnitTest.php | 3 +- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/tests/Unit/ElasticsearchServiceProviderUnitTest.php b/tests/Unit/ElasticsearchServiceProviderUnitTest.php index 3d322a5..4f401e2 100644 --- a/tests/Unit/ElasticsearchServiceProviderUnitTest.php +++ b/tests/Unit/ElasticsearchServiceProviderUnitTest.php @@ -2,12 +2,8 @@ namespace Shift31\LaravelElasticsearch\Tests\Unit; use Mockery; -use Elasticsearch\Client; use Mockery\MockInterface; -use Illuminate\Config\Repository; -use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\AliasLoader; -use Illuminate\Foundation\Application; use Shift31\LaravelElasticsearch\Tests\TestCase; use Shift31\LaravelElasticsearch\ElasticsearchServiceProvider; @@ -15,28 +11,29 @@ class ElasticsearchServiceProviderUnitTest extends TestCase { public function test_it_should_provide_elasticsearch() { - $provider = new ElasticsearchServiceProvider(Mockery::mock(Application::class)); + $provider = new ElasticsearchServiceProvider(Mockery::mock('Illuminate\Foundation\Application')); $this->assertEquals(['elasticsearch'], $provider->provides()); } public function test_boot_method_to_set_config_file() { $configPath = realpath($this->getSourcePath('config')); - $filesMock = Mockery::mock(Filesystem::class, function (MockInterface $m) use ($configPath) { + $filesMock = Mockery::mock('Illuminate\Filesystem\Filesystem', function (MockInterface $m) use ($configPath) { $m->shouldReceive('isDirectory')->with($configPath)->once()->andReturn(true); $m->shouldReceive('isDirectory')->withAnyArgs()->times(3)->andReturn(false); }); - $configMock = Mockery::mock(Repository::class, function (MockInterface $m) use ($configPath) { + $configMock = Mockery::mock('Illuminate\Config\Repository', function (MockInterface $m) use ($configPath) { $m->shouldReceive('package') ->with('shift31/laravel-elasticsearch', $configPath, 'laravel-elasticsearch') ->once() ->andReturnSelf(); }); - $application = Mockery::mock(Application::class, function (MockInterface $m) use ($configMock, $filesMock) { - $m->shouldReceive('offsetGet')->with('config')->once()->andReturn($configMock); - $m->shouldReceive('offsetGet')->with('files')->times(4)->andReturn($filesMock); - $m->shouldReceive('offsetGet')->with('path')->once()->andReturn($this->getSourcePath()); - }); + $application = Mockery::mock('Illuminate\Foundation\Application', + function (MockInterface $m) use ($configMock, $filesMock) { + $m->shouldReceive('offsetGet')->with('config')->once()->andReturn($configMock); + $m->shouldReceive('offsetGet')->with('files')->times(4)->andReturn($filesMock); + $m->shouldReceive('offsetGet')->with('path')->once()->andReturn($this->getSourcePath()); + }); $provider = new ElasticsearchServiceProvider($application); $this->assertNull($provider->boot()); } @@ -44,21 +41,21 @@ public function test_boot_method_to_set_config_file() public function test_register_method_to_set_singleton_elastic_search_client() { $configPath = $this->getSourcePath('config/elasticsearch.php'); - $configMock = Mockery::mock(Repository::class, function (MockInterface $m) { + $configMock = Mockery::mock('Illuminate\Config\Repository', function (MockInterface $m) { $m->shouldReceive('get')->with('elasticsearch')->andReturn([]); }); - $filesMock = Mockery::mock(Filesystem::class, function (MockInterface $m) use ($configPath) { + $filesMock = Mockery::mock('Illuminate\Filesystem\Filesystem', function (MockInterface $m) use ($configPath) { $m->shouldReceive('getRequire') ->with($configPath) ->once()->andReturn([]); }); - $application = Mockery::mock(Application::class, function (MockInterface $m) use ($configMock, $filesMock) { + $application = Mockery::mock('Illuminate\Foundation\Application', function (MockInterface $m) use ($configMock, $filesMock) { $m->shouldReceive('booting')->once()->andReturnSelf(); $m->shouldReceive('offsetGet')->with('config')->andReturn($configMock); $m->shouldReceive('offsetGet')->with('files')->andReturn($filesMock); $m->shouldReceive('singleton')->with('elasticsearch', Mockery::on(function ($closure) { - $this->assertInstanceOf(Client::class, $closure()); + $this->assertInstanceOf('Elasticsearch\Client', $closure()); return true; }))->once()->andReturnSelf(); @@ -69,7 +66,7 @@ public function test_register_method_to_set_singleton_elastic_search_client() public function test_register_method_to_set_elastic_search_facade() { - $application = Mockery::mock(Application::class, function (MockInterface $m) { + $application = Mockery::mock('Illuminate\Foundation\Application', function (MockInterface $m) { $m->shouldReceive('singleton')->once()->andReturnSelf(); $m->shouldReceive('booting')->with(Mockery::on(function ($closure) { $closure(); diff --git a/tests/Unit/EsUnitTest.php b/tests/Unit/EsUnitTest.php index 2c1d814..5d9ce44 100644 --- a/tests/Unit/EsUnitTest.php +++ b/tests/Unit/EsUnitTest.php @@ -3,7 +3,6 @@ use Mockery; use ReflectionClass; -use Illuminate\Foundation\Application; use Shift31\LaravelElasticsearch\Facades\Es; use Shift31\LaravelElasticsearch\Tests\TestCase; use Shift31\LaravelElasticsearch\ElasticsearchServiceProvider; @@ -15,7 +14,7 @@ public function test_to_facade_accessor_matches_service_provider() $class = new ReflectionClass(new Es()); $method = $class->getMethod('getFacadeAccessor'); $method->setAccessible(true); - $provider = new ElasticsearchServiceProvider(Mockery::mock(Application::class)); + $provider = new ElasticsearchServiceProvider(Mockery::mock('Illuminate\Foundation\Application')); $this->assertEquals($provider->provides(), (array)$method->invoke(new Es())); } } \ No newline at end of file From df1214ebf566d564e3996b344eb16c4ff5b50afa Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 13:12:40 +0200 Subject: [PATCH 25/42] Add elastic search simple query test to create index. Update travis settings to install elastic search for integration test. --- .travis.yml | 6 ++++++ composer.json | 3 ++- ...icsearchServiceProviderIntegrationTest.php | 21 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/Integration/ElasticsearchServiceProviderIntegrationTest.php diff --git a/.travis.yml b/.travis.yml index bfedea1..3c7f061 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,12 @@ php: - 5.5 - 5.6 +services: + - elasticsearch + +before_install: + - curl -O https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-0.90.13.deb && sudo dpkg -i --force-confnew elasticsearch-0.90.13.deb && sudo service elasticsearch restart + before_script: - travis_retry composer self-update - travis_retry composer update --prefer-dist --no-interaction diff --git a/composer.json b/composer.json index ee89884..dad437d 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ "squizlabs/php_codesniffer": "^2.8", "phpunit/phpunit": "^4.8", "mockery/mockery": "^0.9.8", - "satooshi/php-coveralls": "^1.0" + "satooshi/php-coveralls": "^1.0", + "orchestra/testbench": "^2.2" }, "autoload": { "psr-0": { diff --git a/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php b/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php new file mode 100644 index 0000000..e7acc4c --- /dev/null +++ b/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php @@ -0,0 +1,21 @@ +create($indexParams); + $this->assertArrayHasKey('acknowledged', $result); + $this->assertTrue($result['acknowledged']); + } + + protected function getPackageProviders() + { + return ['Shift31\LaravelElasticsearch\ElasticsearchServiceProvider']; + } +} From 79d368b7b7edecb296473f7e61f59439b2fb402e Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 14:31:54 +0200 Subject: [PATCH 26/42] Update default config namespace name. Add integration tests path in phpunit.xml. Update README file with how to publish config file. --- README.md | 21 +++------------- phpunit.xml | 3 +++ .../ElasticsearchServiceProvider.php | 4 +-- ...icsearchServiceProviderIntegrationTest.php | 9 +++++++ .../ElasticsearchServiceProviderUnitTest.php | 25 ++++++++++--------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index a87306e..43222d6 100644 --- a/README.md +++ b/README.md @@ -50,20 +50,11 @@ Laravel artisan command ``` $ php artisan config:publish shift31/laravel-elasticsearch ``` - -Manually: Create [app/config/elasticsearch.php](src/config/elasticsearch.php), modifying the following contents -accordingly: +You can always read config parameters with: ```php - array( - 'your.elasticsearch.server:9200' - ), - 'logPath' => 'path/to/your/elasticsearch/log', -); +\Config::get('shift31::elasticsearch'); ``` -Note: The keys of this array should be named according the parameters supported by Elasticsearch\Client. +Note: The keys of this array should be named according the parameters supported by [Elasticsearch\Client](https://github.com/elastic/elasticsearch-php/blob/0.4/src/Elasticsearch/Client.php). 3. In the `'providers'` array in app/config/app.php, add `'Shift31\LaravelElasticsearch\ElasticsearchServiceProvider'`. @@ -77,11 +68,7 @@ $result = Es::search($searchParams); Default Configuration --------------------- -If you return an empty array in the config file: - -`'hosts'` defaults to localhost:9200 - -`'logPath'` defaults to `storage_path() . '/logs/elasticsearch.log'` +If you return an empty array in the config file, Service provider [merges default config with custom config variables](https://github.com/shift31/laravel-elasticsearch/blob/master/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php#L27). [Default config file](src/config/elasticsearch.php) which is publishing by artisan command. diff --git a/phpunit.xml b/phpunit.xml index 699ae2a..78db987 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -13,6 +13,9 @@ ./tests/Unit + + ./tests/Integration + diff --git a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php index bfabdd2..fc80d63 100644 --- a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php @@ -12,7 +12,7 @@ class ElasticsearchServiceProvider extends ServiceProvider */ public function boot() { - $this->package('shift31/laravel-elasticsearch'); + $this->package('shift31/laravel-elasticsearch', 'shift31'); } /** @@ -21,7 +21,7 @@ public function boot() public function register() { $this->app->singleton('elasticsearch', function () { - $customConfig = $this->app->config->get('elasticsearch'); + $customConfig = $this->app->config->get('shift31::elasticsearch'); $defaultConfig = $this->loadDefaultConfig(); return new Client(array_merge($defaultConfig, $customConfig)); diff --git a/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php b/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php index e7acc4c..ee29bdb 100644 --- a/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php +++ b/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php @@ -2,6 +2,7 @@ namespace Shift31\LaravelElasticsearch\Tests\Integration; use Orchestra\Testbench\TestCase; +use Illuminate\Support\Facades\Config; use Shift31\LaravelElasticsearch\Facades\Es; class ElasticsearchServiceProviderIntegrationTest extends TestCase @@ -14,6 +15,14 @@ public function test_elasticsearch_simple_create_request() $this->assertTrue($result['acknowledged']); } + public function test_get_elasticsearch_config() + { + $config = Config::get('shift31::elasticsearch'); + $this->assertArrayHasKey('hosts', $config); + $this->assertArrayHasKey('logPath', $config); + $this->assertArrayHasKey('logLevel', $config); + } + protected function getPackageProviders() { return ['Shift31\LaravelElasticsearch\ElasticsearchServiceProvider']; diff --git a/tests/Unit/ElasticsearchServiceProviderUnitTest.php b/tests/Unit/ElasticsearchServiceProviderUnitTest.php index 4f401e2..8e273a9 100644 --- a/tests/Unit/ElasticsearchServiceProviderUnitTest.php +++ b/tests/Unit/ElasticsearchServiceProviderUnitTest.php @@ -24,7 +24,7 @@ public function test_boot_method_to_set_config_file() }); $configMock = Mockery::mock('Illuminate\Config\Repository', function (MockInterface $m) use ($configPath) { $m->shouldReceive('package') - ->with('shift31/laravel-elasticsearch', $configPath, 'laravel-elasticsearch') + ->with('shift31/laravel-elasticsearch', $configPath, 'shift31') ->once() ->andReturnSelf(); }); @@ -42,24 +42,25 @@ public function test_register_method_to_set_singleton_elastic_search_client() { $configPath = $this->getSourcePath('config/elasticsearch.php'); $configMock = Mockery::mock('Illuminate\Config\Repository', function (MockInterface $m) { - $m->shouldReceive('get')->with('elasticsearch')->andReturn([]); + $m->shouldReceive('get')->with('shift31::elasticsearch')->andReturn([]); }); $filesMock = Mockery::mock('Illuminate\Filesystem\Filesystem', function (MockInterface $m) use ($configPath) { $m->shouldReceive('getRequire') ->with($configPath) ->once()->andReturn([]); }); - $application = Mockery::mock('Illuminate\Foundation\Application', function (MockInterface $m) use ($configMock, $filesMock) { - $m->shouldReceive('booting')->once()->andReturnSelf(); - $m->shouldReceive('offsetGet')->with('config')->andReturn($configMock); - $m->shouldReceive('offsetGet')->with('files')->andReturn($filesMock); - $m->shouldReceive('singleton')->with('elasticsearch', - Mockery::on(function ($closure) { - $this->assertInstanceOf('Elasticsearch\Client', $closure()); + $application = Mockery::mock('Illuminate\Foundation\Application', + function (MockInterface $m) use ($configMock, $filesMock) { + $m->shouldReceive('booting')->once()->andReturnSelf(); + $m->shouldReceive('offsetGet')->with('config')->andReturn($configMock); + $m->shouldReceive('offsetGet')->with('files')->andReturn($filesMock); + $m->shouldReceive('singleton')->with('elasticsearch', + Mockery::on(function ($closure) { + $this->assertInstanceOf('Elasticsearch\Client', $closure()); - return true; - }))->once()->andReturnSelf(); - }); + return true; + }))->once()->andReturnSelf(); + }); $provider = new ElasticsearchServiceProvider($application); $this->assertNull($provider->register()); } From d1b9d014e6a60aeab7fc12bdd7ed059fee90282a Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 15:19:10 +0200 Subject: [PATCH 27/42] Update readme file for 4.0 version. --- README.md | 50 +++++++------------ .../ElasticsearchServiceProvider.php | 2 + 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 43222d6..ffff2a6 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,32 @@ -Laravel Elasticsearch Service Provider (v4.0.x) +Laravel Elasticsearch Service Provider (4.0.0) ================================================ [![Latest Stable Version](https://poser.pugx.org/shift31/laravel-elasticsearch/v/stable)](https://packagist.org/packages/shift31/laravel-elasticsearch) [![Total Downloads](https://poser.pugx.org/shift31/laravel-elasticsearch/downloads)](https://packagist.org/packages/shift31/laravel-elasticsearch) -[![Build Status](https://travis-ci.org/shift31/laravel-elasticsearch.svg?branch=master)](https://travis-ci.org/shift31/laravel-elasticsearch) -[![Coverage Status](https://coveralls.io/repos/github/shift31/laravel-elasticsearch/badge.svg?branch=master)](https://coveralls.io/github/shift31/laravel-elasticsearch?branch=master) +[![Build Status](https://travis-ci.org/shift31/laravel-elasticsearch.svg?branch=4.0)](https://travis-ci.org/shift31/laravel-elasticsearch) +[![Coverage Status](https://coveralls.io/repos/github/shift31/laravel-elasticsearch/badge.svg?branch=4.0)](https://coveralls.io/github/shift31/laravel-elasticsearch?branch=master) [![License](https://poser.pugx.org/shift31/laravel-elasticsearch/license)](https://packagist.org/packages/shift31/laravel-elasticsearch) -This is a Laravel (4+) Service Provider for the official Elasticsearch low-level client: -http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/index.html - +This is a Laravel (4.2) Service Provider for the [official Elasticsearch low-level client](http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/index.html): Version Matrix ------------------ -Since there are breaking changes in Elasticsearch 1.0, your version of Elasticsearch must match the version of this -library, which matches the version of the Elasticsearch low-level client. If you are using a version older than 1.0, you - must install the `0.4` laravel-elasticsearch branch. Otherwise, use the `1.0` branch. - -The master branch will always track the latest version. +Since there are breaking changes in Elasticsearch versions, your version of Elasticsearch must match the version of this +library, which matches the version of the Elasticsearch low-level client. -Old ---- -| Elasticsearch Version | laravel-elasticsearch branch | -| --------------------- | ---------------------------- | -| >= 1.0 | 1.0, 2.0 | -| <= 0.90.* | 0.4 | +|Shift31/laravel-elasticsearch| Elasticsearch | Laravel | +| :---: | :---: | :---: | +| 0.4| <= 0.90.* | 4.2 | +| 1.0, 2.0| \>= 1.0 | 4.x, 5.x | +|4.0| <= 0.90.* | 4.2| +|4.1| \>= 1.0 <= 2.0 | 4.2| +|4.2| \>= 2.0 <= 5.0| 4.2| +|4.5| \>= 5.0| 4.2| +|5.0| <= 0.90.* | 5.x| +|5.1| \>= 1.0 <= 2.0 | 5.x| +|5.2| \>= 2.0 <= 5.0| 5.x| +|5.5| \>= 5.0| 5.x| -Attention: Until we launch new versions please keep using old versions and don't use dev-master branch! - -New (Under development!) ------------------- -| Elasticsearch Version | Laravel | laravel-elasticsearch branch | -| --------------------- |---------| ---------------------------- | -| <= 0.90.* | 4.2 | 4.0 | -| 1.0 | 4.2 | 4.1 | -| 2.0 | 4.2 | 4.2 | -| 5.0 | 4.2 | 4.5 | -| <= 0.90.* | 5.2 | 5.0 | -| 1.0 | 5.2 | 5.1 | -| 2.0 | 5.2 | 5.2 | -| 5.0 | 5.x | 5.5 | +Attention: Until we launch new versions please keep using old stable versions (which are created as a branch) and don't use dev-master branch! Usage ----- diff --git a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php index fc80d63..e95805d 100644 --- a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php @@ -7,6 +7,8 @@ class ElasticsearchServiceProvider extends ServiceProvider { + const VERSION = '4.0.0'; + /** * @inheritdoc */ From 2e4f5618de2e04b1c6fa49e9fb317164a272b488 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 15:51:16 +0200 Subject: [PATCH 28/42] Update composer file with elastic search 1.0 version support. Update readme file and version tags. --- .travis.yml | 2 +- README.md | 8 ++++---- composer.json | 2 +- .../LaravelElasticsearch/ElasticsearchServiceProvider.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3c7f061..c8d6213 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ services: - elasticsearch before_install: - - curl -O https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-0.90.13.deb && sudo dpkg -i --force-confnew elasticsearch-0.90.13.deb && sudo service elasticsearch restart + - curl -O https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.3.deb && sudo dpkg -i --force-confnew elasticsearch-1.7.3.deb && sudo service elasticsearch restart before_script: - travis_retry composer self-update diff --git a/README.md b/README.md index ffff2a6..0b15945 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -Laravel Elasticsearch Service Provider (4.0.0) +Laravel Elasticsearch Service Provider (4.1.0) ================================================ [![Latest Stable Version](https://poser.pugx.org/shift31/laravel-elasticsearch/v/stable)](https://packagist.org/packages/shift31/laravel-elasticsearch) [![Total Downloads](https://poser.pugx.org/shift31/laravel-elasticsearch/downloads)](https://packagist.org/packages/shift31/laravel-elasticsearch) -[![Build Status](https://travis-ci.org/shift31/laravel-elasticsearch.svg?branch=4.0)](https://travis-ci.org/shift31/laravel-elasticsearch) -[![Coverage Status](https://coveralls.io/repos/github/shift31/laravel-elasticsearch/badge.svg?branch=4.0)](https://coveralls.io/github/shift31/laravel-elasticsearch?branch=master) +[![Build Status](https://travis-ci.org/shift31/laravel-elasticsearch.svg?branch=4.1)](https://travis-ci.org/shift31/laravel-elasticsearch) +[![Coverage Status](https://coveralls.io/repos/github/shift31/laravel-elasticsearch/badge.svg?branch=4.1)](https://coveralls.io/github/shift31/laravel-elasticsearch?branch=master) [![License](https://poser.pugx.org/shift31/laravel-elasticsearch/license)](https://packagist.org/packages/shift31/laravel-elasticsearch) This is a Laravel (4.2) Service Provider for the [official Elasticsearch low-level client](http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/index.html): @@ -30,7 +30,7 @@ Attention: Until we launch new versions please keep using old stable versions (w Usage ----- -1. Run `composer require shift31/laravel-elasticsearch:~4.0.0` +1. Run `composer require shift31/laravel-elasticsearch:~4.1.0` 2. Publish config file diff --git a/composer.json b/composer.json index dad437d..a63fff9 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "require": { "php": ">=5.4.0 <=7.0.0", "laravel/framework": "~4.2.0", - "elasticsearch/elasticsearch": "~0.4" + "elasticsearch/elasticsearch": "~1.0" }, "require-dev": { "squizlabs/php_codesniffer": "^2.8", diff --git a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php index e95805d..30af58c 100644 --- a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php @@ -7,7 +7,7 @@ class ElasticsearchServiceProvider extends ServiceProvider { - const VERSION = '4.0.0'; + const VERSION = '4.1.0'; /** * @inheritdoc From dd16e914b3dad809de9ab5fca36edb088b0cec5a Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 16:05:43 +0200 Subject: [PATCH 29/42] Update elastic search version in travis config. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c8d6213..de4cced 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ services: - elasticsearch before_install: - - curl -O https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.3.deb && sudo dpkg -i --force-confnew elasticsearch-1.7.3.deb && sudo service elasticsearch restart + - curl -O https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.6.deb && sudo dpkg -i --force-confnew elasticsearch-1.7.6.deb && sudo service elasticsearch restart before_script: - travis_retry composer self-update From 5480e632ca7631456c5dc2887781339f873bca88 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 16:13:44 +0200 Subject: [PATCH 30/42] Update elastic search deb download path. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index de4cced..12e5e71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ services: - elasticsearch before_install: - - curl -O https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.6.deb && sudo dpkg -i --force-confnew elasticsearch-1.7.6.deb && sudo service elasticsearch restart + - curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.7.6.deb && sudo dpkg -i elasticsearch-1.7.6.deb && sudo service elasticsearch restart before_script: - travis_retry composer self-update From c33a07120db9ac2bf5b5273bfc48d6116ebf955e Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 16:27:37 +0200 Subject: [PATCH 31/42] Change .travis.yml file for install elasticsearch 1.7 --- .travis.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 12e5e71..3fdbe9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,16 @@ php: - 5.5 - 5.6 +addons: + apt: + sources: + - elasticsearch-1.7 + packages: + - elasticsearch + services: - elasticsearch -before_install: - - curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.7.6.deb && sudo dpkg -i elasticsearch-1.7.6.deb && sudo service elasticsearch restart - before_script: - travis_retry composer self-update - travis_retry composer update --prefer-dist --no-interaction From 4ffe0ec07d7c0e86930b2d341fc8ee144c195b91 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 17:38:55 +0200 Subject: [PATCH 32/42] Update changes for elastic search 2.x versions. New config parameters added based on elasticsearch-php library. --- .travis.yml | 2 +- README.md | 9 +++++---- composer.json | 5 +++-- .../ElasticsearchServiceProvider.php | 15 ++++++++++----- src/config/elasticsearch.php | 1 + ...lasticsearchServiceProviderIntegrationTest.php | 11 +++++++++++ .../Unit/ElasticsearchServiceProviderUnitTest.php | 6 +++++- 7 files changed, 36 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3fdbe9e..5f023ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ php: addons: apt: sources: - - elasticsearch-1.7 + - elasticsearch-2.4 packages: - elasticsearch diff --git a/README.md b/README.md index 0b15945..7333f67 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -Laravel Elasticsearch Service Provider (4.1.0) +Laravel Elasticsearch Service Provider (4.2.0) ================================================ [![Latest Stable Version](https://poser.pugx.org/shift31/laravel-elasticsearch/v/stable)](https://packagist.org/packages/shift31/laravel-elasticsearch) [![Total Downloads](https://poser.pugx.org/shift31/laravel-elasticsearch/downloads)](https://packagist.org/packages/shift31/laravel-elasticsearch) -[![Build Status](https://travis-ci.org/shift31/laravel-elasticsearch.svg?branch=4.1)](https://travis-ci.org/shift31/laravel-elasticsearch) -[![Coverage Status](https://coveralls.io/repos/github/shift31/laravel-elasticsearch/badge.svg?branch=4.1)](https://coveralls.io/github/shift31/laravel-elasticsearch?branch=master) +[![Build Status](https://travis-ci.org/shift31/laravel-elasticsearch.svg?branch=4.2)](https://travis-ci.org/shift31/laravel-elasticsearch) +[![Coverage Status](https://coveralls.io/repos/github/shift31/laravel-elasticsearch/badge.svg?branch=4.2)](https://coveralls.io/github/shift31/laravel-elasticsearch?branch=master) [![License](https://poser.pugx.org/shift31/laravel-elasticsearch/license)](https://packagist.org/packages/shift31/laravel-elasticsearch) This is a Laravel (4.2) Service Provider for the [official Elasticsearch low-level client](http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/index.html): @@ -30,7 +30,7 @@ Attention: Until we launch new versions please keep using old stable versions (w Usage ----- -1. Run `composer require shift31/laravel-elasticsearch:~4.1.0` +1. Run `composer require shift31/laravel-elasticsearch:~4.2.0` 2. Publish config file @@ -57,6 +57,7 @@ $result = Es::search($searchParams); Default Configuration --------------------- If you return an empty array in the config file, Service provider [merges default config with custom config variables](https://github.com/shift31/laravel-elasticsearch/blob/master/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php#L27). +If you want to disable elastic search logging, Just set in custom config file ['logPath' => null](https://github.com/shift31/laravel-elasticsearch/blob/master/src/config/elasticsearch.php#L5) then logging will be disabled. [Default config file](src/config/elasticsearch.php) which is publishing by artisan command. diff --git a/composer.json b/composer.json index a63fff9..e9d5ac5 100644 --- a/composer.json +++ b/composer.json @@ -10,14 +10,15 @@ "require": { "php": ">=5.4.0 <=7.0.0", "laravel/framework": "~4.2.0", - "elasticsearch/elasticsearch": "~1.0" + "elasticsearch/elasticsearch": "~2.0" }, "require-dev": { "squizlabs/php_codesniffer": "^2.8", "phpunit/phpunit": "^4.8", "mockery/mockery": "^0.9.8", "satooshi/php-coveralls": "^1.0", - "orchestra/testbench": "^2.2" + "orchestra/testbench": "^2.2", + "monolog/monolog": "~1.0" }, "autoload": { "psr-0": { diff --git a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php index 30af58c..8bf1b56 100644 --- a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php @@ -1,13 +1,13 @@ app->singleton('elasticsearch', function () { - $customConfig = $this->app->config->get('shift31::elasticsearch'); - $defaultConfig = $this->loadDefaultConfig(); + $config = array_merge($this->loadDefaultConfig(), $this->app->config->get('shift31::elasticsearch')); + $builder = new ClientBuilder(); + $builder->setHosts($config['hosts']); + $builder->setRetries($config['retries']); + if (is_null($config['logPath']) == false) { + $builder->setLogger(ClientBuilder::defaultLogger($config['logPath'], $config['logLevel'])); + } - return new Client(array_merge($defaultConfig, $customConfig)); + return $builder->build(); }); $this->app->booting(function () { $loader = AliasLoader::getInstance(); diff --git a/src/config/elasticsearch.php b/src/config/elasticsearch.php index 5d5bf32..789ec93 100644 --- a/src/config/elasticsearch.php +++ b/src/config/elasticsearch.php @@ -4,4 +4,5 @@ 'hosts' => ['localhost:9200'], 'logPath' => storage_path('logs/elastic-search.log'), 'logLevel' => 400, + 'retries' => 1, ]; diff --git a/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php b/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php index ee29bdb..1d90f70 100644 --- a/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php +++ b/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php @@ -15,6 +15,17 @@ public function test_elasticsearch_simple_create_request() $this->assertTrue($result['acknowledged']); } + public function test_to_see_elasticsearch_log_file() + { + $logPath = Config::get('shift31::elasticsearch.logPath'); + Config::set('shift31::elasticsearch.logLevel', 100); + $indexParams['index'] = 'shift31'; + $result = Es::indices()->delete($indexParams); + $this->assertArrayHasKey('acknowledged', $result); + $this->assertTrue($result['acknowledged']); + $this->assertTrue(file_exists($logPath)); + } + public function test_get_elasticsearch_config() { $config = Config::get('shift31::elasticsearch'); diff --git a/tests/Unit/ElasticsearchServiceProviderUnitTest.php b/tests/Unit/ElasticsearchServiceProviderUnitTest.php index 8e273a9..e732b72 100644 --- a/tests/Unit/ElasticsearchServiceProviderUnitTest.php +++ b/tests/Unit/ElasticsearchServiceProviderUnitTest.php @@ -42,7 +42,11 @@ public function test_register_method_to_set_singleton_elastic_search_client() { $configPath = $this->getSourcePath('config/elasticsearch.php'); $configMock = Mockery::mock('Illuminate\Config\Repository', function (MockInterface $m) { - $m->shouldReceive('get')->with('shift31::elasticsearch')->andReturn([]); + $m->shouldReceive('get')->with('shift31::elasticsearch')->andReturn([ + 'hosts' => [], + 'logPath' => null, + 'retries' => 1 + ]); }); $filesMock = Mockery::mock('Illuminate\Filesystem\Filesystem', function (MockInterface $m) use ($configPath) { $m->shouldReceive('getRequire') From 10c3a1fc69583882e3c0f696505f00813de7e2ae Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 17:51:29 +0200 Subject: [PATCH 33/42] Change config file to use with ClientBuilder::fromConfig method. --- README.md | 2 +- .../ElasticsearchServiceProvider.php | 11 +++-------- src/config/elasticsearch.php | 3 +-- .../ElasticsearchServiceProviderIntegrationTest.php | 10 ++++++---- tests/Unit/ElasticsearchServiceProviderUnitTest.php | 2 -- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 7333f67..ed9c78c 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ $result = Es::search($searchParams); Default Configuration --------------------- If you return an empty array in the config file, Service provider [merges default config with custom config variables](https://github.com/shift31/laravel-elasticsearch/blob/master/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php#L27). -If you want to disable elastic search logging, Just set in custom config file ['logPath' => null](https://github.com/shift31/laravel-elasticsearch/blob/master/src/config/elasticsearch.php#L5) then logging will be disabled. +For custom config file question please see [this](https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_building_the_client_from_a_configuration_hash) elastic search configuration page. [Default config file](src/config/elasticsearch.php) which is publishing by artisan command. diff --git a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php index 8bf1b56..a0990f2 100644 --- a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php @@ -24,15 +24,10 @@ public function register() { $this->app->singleton('elasticsearch', function () { $config = array_merge($this->loadDefaultConfig(), $this->app->config->get('shift31::elasticsearch')); - $builder = new ClientBuilder(); - $builder->setHosts($config['hosts']); - $builder->setRetries($config['retries']); - if (is_null($config['logPath']) == false) { - $builder->setLogger(ClientBuilder::defaultLogger($config['logPath'], $config['logLevel'])); - } - - return $builder->build(); + + return ClientBuilder::fromConfig($config); }); + $this->app->booting(function () { $loader = AliasLoader::getInstance(); $loader->alias('Es', 'Shift31\LaravelElasticsearch\Facades\Es'); diff --git a/src/config/elasticsearch.php b/src/config/elasticsearch.php index 789ec93..2065e63 100644 --- a/src/config/elasticsearch.php +++ b/src/config/elasticsearch.php @@ -2,7 +2,6 @@ return [ 'hosts' => ['localhost:9200'], - 'logPath' => storage_path('logs/elastic-search.log'), - 'logLevel' => 400, + 'logger' => Elasticsearch\ClientBuilder::defaultLogger(storage_path('logs/elastic-search.log'), 400), 'retries' => 1, ]; diff --git a/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php b/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php index 1d90f70..5697504 100644 --- a/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php +++ b/tests/Integration/ElasticsearchServiceProviderIntegrationTest.php @@ -1,6 +1,7 @@ delete($indexParams); $this->assertArrayHasKey('acknowledged', $result); @@ -30,8 +32,8 @@ public function test_get_elasticsearch_config() { $config = Config::get('shift31::elasticsearch'); $this->assertArrayHasKey('hosts', $config); - $this->assertArrayHasKey('logPath', $config); - $this->assertArrayHasKey('logLevel', $config); + $this->assertArrayHasKey('logger', $config); + $this->assertArrayHasKey('retries', $config); } protected function getPackageProviders() diff --git a/tests/Unit/ElasticsearchServiceProviderUnitTest.php b/tests/Unit/ElasticsearchServiceProviderUnitTest.php index e732b72..7089ab2 100644 --- a/tests/Unit/ElasticsearchServiceProviderUnitTest.php +++ b/tests/Unit/ElasticsearchServiceProviderUnitTest.php @@ -44,8 +44,6 @@ public function test_register_method_to_set_singleton_elastic_search_client() $configMock = Mockery::mock('Illuminate\Config\Repository', function (MockInterface $m) { $m->shouldReceive('get')->with('shift31::elasticsearch')->andReturn([ 'hosts' => [], - 'logPath' => null, - 'retries' => 1 ]); }); $filesMock = Mockery::mock('Illuminate\Filesystem\Filesystem', function (MockInterface $m) use ($configPath) { From a1bb2c4f0ef895569efa446a726cce0790411ce3 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 18:06:59 +0200 Subject: [PATCH 34/42] Change branch alias tag in composer.json file. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e9d5ac5..85dc887 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ }, "extra": { "branch-alias": { - "dev-master": "4.0.x-dev" + "dev-master": "4.2.x-dev" } }, "scripts": { From 10e04d5b68211760f326ba36166b6e17cc9c0242 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 18:43:56 +0200 Subject: [PATCH 35/42] Changes for elastic search 5.x. - ServiceProvider version updated. - composer.json packages updated to use new php versions. - composer.json phpunit version updated. - README version changes added. --- .travis.yml | 5 ++--- README.md | 16 ++++++++-------- composer.json | 8 ++++---- .../ElasticsearchServiceProvider.php | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f023ba..ac72420 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,13 @@ language: php php: - - 5.4 - - 5.5 - 5.6 + - 7.0 addons: apt: sources: - - elasticsearch-2.4 + - elasticsearch-5.0 packages: - elasticsearch diff --git a/README.md b/README.md index ed9c78c..3fd4a91 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -Laravel Elasticsearch Service Provider (4.2.0) +Laravel Elasticsearch Service Provider (4.5.0) ================================================ [![Latest Stable Version](https://poser.pugx.org/shift31/laravel-elasticsearch/v/stable)](https://packagist.org/packages/shift31/laravel-elasticsearch) [![Total Downloads](https://poser.pugx.org/shift31/laravel-elasticsearch/downloads)](https://packagist.org/packages/shift31/laravel-elasticsearch) -[![Build Status](https://travis-ci.org/shift31/laravel-elasticsearch.svg?branch=4.2)](https://travis-ci.org/shift31/laravel-elasticsearch) -[![Coverage Status](https://coveralls.io/repos/github/shift31/laravel-elasticsearch/badge.svg?branch=4.2)](https://coveralls.io/github/shift31/laravel-elasticsearch?branch=master) +[![Build Status](https://travis-ci.org/shift31/laravel-elasticsearch.svg?branch=4.5)](https://travis-ci.org/shift31/laravel-elasticsearch) +[![Coverage Status](https://coveralls.io/repos/github/shift31/laravel-elasticsearch/badge.svg?branch=4.5)](https://coveralls.io/github/shift31/laravel-elasticsearch?branch=master) [![License](https://poser.pugx.org/shift31/laravel-elasticsearch/license)](https://packagist.org/packages/shift31/laravel-elasticsearch) -This is a Laravel (4.2) Service Provider for the [official Elasticsearch low-level client](http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/index.html): +This is a Laravel (4.2) Service Provider for the [official Elasticsearch low-level client](http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/5.0/index.html). Version Matrix ------------------ @@ -30,7 +30,7 @@ Attention: Until we launch new versions please keep using old stable versions (w Usage ----- -1. Run `composer require shift31/laravel-elasticsearch:~4.2.0` +1. Run `composer require shift31/laravel-elasticsearch:~4.5.0` 2. Publish config file @@ -42,7 +42,7 @@ You can always read config parameters with: ```php \Config::get('shift31::elasticsearch'); ``` -Note: The keys of this array should be named according the parameters supported by [Elasticsearch\Client](https://github.com/elastic/elasticsearch-php/blob/0.4/src/Elasticsearch/Client.php). +Note: The keys of this array should be named according the parameters supported by [Elasticsearch\ClientBuilder](https://github.com/elastic/elasticsearch-php/blob/5.0/src/Elasticsearch/ClientBuilder.php#L119). 3. In the `'providers'` array in app/config/app.php, add `'Shift31\LaravelElasticsearch\ElasticsearchServiceProvider'`. @@ -56,8 +56,8 @@ $result = Es::search($searchParams); Default Configuration --------------------- -If you return an empty array in the config file, Service provider [merges default config with custom config variables](https://github.com/shift31/laravel-elasticsearch/blob/master/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php#L27). -For custom config file question please see [this](https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_building_the_client_from_a_configuration_hash) elastic search configuration page. +If you return an empty array in the config file, Service provider [merges default config with custom config variables](src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php). +For custom config file question please see [this](https://www.elastic.co/guide/en/elasticsearch/client/php-api/5.0/_configuration.html#_building_the_client_from_a_configuration_hash) elastic search configuration page. [Default config file](src/config/elasticsearch.php) which is publishing by artisan command. diff --git a/composer.json b/composer.json index 85dc887..b7e98ca 100644 --- a/composer.json +++ b/composer.json @@ -8,13 +8,13 @@ } ], "require": { - "php": ">=5.4.0 <=7.0.0", + "php": ">=5.6 <=7.1", "laravel/framework": "~4.2.0", - "elasticsearch/elasticsearch": "~2.0" + "elasticsearch/elasticsearch": "~5.0" }, "require-dev": { "squizlabs/php_codesniffer": "^2.8", - "phpunit/phpunit": "^4.8", + "phpunit/phpunit": "^5.7", "mockery/mockery": "^0.9.8", "satooshi/php-coveralls": "^1.0", "orchestra/testbench": "^2.2", @@ -32,7 +32,7 @@ }, "extra": { "branch-alias": { - "dev-master": "4.2.x-dev" + "dev-master": "4.5.x-dev" } }, "scripts": { diff --git a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php index a0990f2..24730be 100644 --- a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php @@ -7,7 +7,7 @@ class ElasticsearchServiceProvider extends ServiceProvider { - const VERSION = '4.2.0'; + const VERSION = '4.5.0'; /** * @inheritdoc From 6f867ef7e2841f3522bb62007a6dde54e120ece4 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Mon, 27 Feb 2017 22:09:04 +0200 Subject: [PATCH 36/42] Update phpunit.xml file remove black list add white list. --- phpunit.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 78db987..d840e70 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -18,9 +18,9 @@ - - ./vendor/* - + + ./src/Shift31/LaravelElasticsearch + From f1f840c3cace51b5e7c7983ad48884d2642e4a57 Mon Sep 17 00:00:00 2001 From: Candas Minareci Date: Sat, 4 Mar 2017 22:45:54 +0200 Subject: [PATCH 37/42] Update composer to not limit php support with php 7.1 - Update readme file with new version number - Update service provider with new version number --- README.md | 2 +- composer.json | 2 +- .../LaravelElasticsearch/ElasticsearchServiceProvider.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3fd4a91..a2b4f51 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Laravel Elasticsearch Service Provider (4.5.0) +Laravel Elasticsearch Service Provider (4.5.1) ================================================ [![Latest Stable Version](https://poser.pugx.org/shift31/laravel-elasticsearch/v/stable)](https://packagist.org/packages/shift31/laravel-elasticsearch) [![Total Downloads](https://poser.pugx.org/shift31/laravel-elasticsearch/downloads)](https://packagist.org/packages/shift31/laravel-elasticsearch) diff --git a/composer.json b/composer.json index b7e98ca..60b6dc1 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ } ], "require": { - "php": ">=5.6 <=7.1", + "php": ">=5.6", "laravel/framework": "~4.2.0", "elasticsearch/elasticsearch": "~5.0" }, diff --git a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php index 24730be..6351863 100644 --- a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php @@ -7,7 +7,7 @@ class ElasticsearchServiceProvider extends ServiceProvider { - const VERSION = '4.5.0'; + const VERSION = '4.5.1'; /** * @inheritdoc From f6fd2f41c3f5fbce075be282e2ddbc8ee3bd5f62 Mon Sep 17 00:00:00 2001 From: Julio Foulquie Date: Mon, 17 Dec 2018 16:33:35 -0300 Subject: [PATCH 38/42] Make it compatible with Laravel 5 and php 7.3 --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 60b6dc1..e12ffa3 100644 --- a/composer.json +++ b/composer.json @@ -8,8 +8,8 @@ } ], "require": { - "php": ">=5.6", - "laravel/framework": "~4.2.0", + "php": ">=5.6 <=7.3", + "illuminate/support": "5.*", "elasticsearch/elasticsearch": "~5.0" }, "require-dev": { @@ -17,7 +17,7 @@ "phpunit/phpunit": "^5.7", "mockery/mockery": "^0.9.8", "satooshi/php-coveralls": "^1.0", - "orchestra/testbench": "^2.2", + "orchestra/testbench": "^3.4", "monolog/monolog": "~1.0" }, "autoload": { From d2e7c8c0859d14dbbdd1808a58d6f68219d369c3 Mon Sep 17 00:00:00 2001 From: Julio Foulquie Date: Mon, 17 Dec 2018 16:51:30 -0300 Subject: [PATCH 39/42] Make provider compatible with Laravel 5.x and add autodiscover --- composer.json | 8 +++++++ .../ElasticsearchServiceProvider.php | 21 ++++--------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index e12ffa3..d8437ab 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,14 @@ "extra": { "branch-alias": { "dev-master": "4.5.x-dev" + }, + "laravel": { + "providers": [ + "Shift31\\LaravelElasticsearch\\ElasticsearchServiceProvider" + ], + "aliases": { + "Es": "Shift31\\LaravelElasticsearch\\Facades\\Es" + } } }, "scripts": { diff --git a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php index 6351863..5e40663 100644 --- a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php @@ -2,19 +2,17 @@ namespace Shift31\LaravelElasticsearch; use Elasticsearch\ClientBuilder; -use Illuminate\Foundation\AliasLoader; use Illuminate\Support\ServiceProvider; class ElasticsearchServiceProvider extends ServiceProvider { - const VERSION = '4.5.1'; + const VERSION = '5.0.0'; /** * @inheritdoc */ public function boot() { - $this->package('shift31/laravel-elasticsearch', 'shift31'); } /** @@ -22,15 +20,9 @@ public function boot() */ public function register() { - $this->app->singleton('elasticsearch', function () { - $config = array_merge($this->loadDefaultConfig(), $this->app->config->get('shift31::elasticsearch')); - - return ClientBuilder::fromConfig($config); - }); - - $this->app->booting(function () { - $loader = AliasLoader::getInstance(); - $loader->alias('Es', 'Shift31\LaravelElasticsearch\Facades\Es'); + $this->mergeConfigFrom(realpath(__DIR__ . '/../../config/elasticsearch.php'), 'elasticsearch'); + $this->app->singleton('elasticsearch', function ($app) { + return ClientBuilder::fromConfig($app->config->get('elasticsearch')); }); } @@ -41,9 +33,4 @@ public function provides() { return ['elasticsearch']; } - - private function loadDefaultConfig() - { - return $this->app->files->getRequire(realpath(__DIR__ . '/../../config/elasticsearch.php')); - } } From 975b353472b8b9e22228e07a1b9ed59f791f4f42 Mon Sep 17 00:00:00 2001 From: Julio Foulquie Date: Thu, 5 Mar 2020 17:35:13 -0300 Subject: [PATCH 40/42] support for laravel 6 and 7 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index d8437ab..8e80cf5 100644 --- a/composer.json +++ b/composer.json @@ -8,8 +8,8 @@ } ], "require": { - "php": ">=5.6 <=7.3", - "illuminate/support": "5.*", + "php": ">=5.6", + "illuminate/support": "~5|~6|~7", "elasticsearch/elasticsearch": "~5.0" }, "require-dev": { From d7f1e38e43b8f853638a74818793caee394d5b64 Mon Sep 17 00:00:00 2001 From: Julio Foulquie Date: Thu, 5 Mar 2020 17:08:51 -0300 Subject: [PATCH 41/42] Create the logger on the service provider instead of on the config file, making the config file cacheable --- .../ElasticsearchServiceProvider.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php index 5e40663..9a3bca3 100644 --- a/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php +++ b/src/Shift31/LaravelElasticsearch/ElasticsearchServiceProvider.php @@ -2,7 +2,9 @@ namespace Shift31\LaravelElasticsearch; use Elasticsearch\ClientBuilder; +use Illuminate\Support\Arr; use Illuminate\Support\ServiceProvider; +use Monolog\Logger; class ElasticsearchServiceProvider extends ServiceProvider { @@ -22,6 +24,18 @@ public function register() { $this->mergeConfigFrom(realpath(__DIR__ . '/../../config/elasticsearch.php'), 'elasticsearch'); $this->app->singleton('elasticsearch', function ($app) { + if (empty($app->config->get('elasticsearch.logger'))) { + $config = $app->config->get('elasticsearch'); + + $logPath = Arr::get($config, 'elasticsearch.logPath', storage_path('logs/elastic-search.log')); + $logLevel = Arr::get($config, 'elasticsearch.logLevel', Logger::WARNING); + $logger = ClientBuilder::defaultLogger($logPath, $logLevel); + unset($config['logLevel']); + unset($config['logPath']); + $config['logger'] = $logger; + $app->config->set('elasticsearch', $config); + } + return ClientBuilder::fromConfig($app->config->get('elasticsearch')); }); } From 0dbdce16ea8321ffd7746eacd0ebf83ecfe67075 Mon Sep 17 00:00:00 2001 From: Julio Foulquie Date: Thu, 29 Oct 2020 13:04:28 -0300 Subject: [PATCH 42/42] Remove redundant deps that are provided by testbench --- composer.json | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 8e80cf5..72a7af2 100644 --- a/composer.json +++ b/composer.json @@ -8,17 +8,14 @@ } ], "require": { - "php": ">=5.6", - "illuminate/support": "~5|~6|~7", + "php": ">=7.2", + "illuminate/support": "^6.0|^7.0|^8.0", "elasticsearch/elasticsearch": "~5.0" }, "require-dev": { "squizlabs/php_codesniffer": "^2.8", - "phpunit/phpunit": "^5.7", - "mockery/mockery": "^0.9.8", "satooshi/php-coveralls": "^1.0", - "orchestra/testbench": "^3.4", - "monolog/monolog": "~1.0" + "orchestra/testbench": "^4.0|^5.0|^6.0" }, "autoload": { "psr-0": { @@ -35,12 +32,12 @@ "dev-master": "4.5.x-dev" }, "laravel": { - "providers": [ - "Shift31\\LaravelElasticsearch\\ElasticsearchServiceProvider" - ], - "aliases": { - "Es": "Shift31\\LaravelElasticsearch\\Facades\\Es" - } + "providers": [ + "Shift31\\LaravelElasticsearch\\ElasticsearchServiceProvider" + ], + "aliases": { + "Es": "Shift31\\LaravelElasticsearch\\Facades\\Es" + } } }, "scripts": { @@ -49,4 +46,4 @@ "vendor/bin/phpunit" ] } -} +} \ No newline at end of file