Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #1

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
9c19d34
delete unnecessary folders
candasm Sep 20, 2016
0e00301
Add laravel/framework for require package because of AliasLoader and …
candasm Sep 20, 2016
4211fbe
add elasticsearch default config file
candasm Sep 20, 2016
727e3ee
Update Service Providers for publish elastic search config file.
candasm Sep 20, 2016
e89f7c9
Merge branch 'feature/structure-cleanup' into develop
candasm Sep 20, 2016
5a985c9
Merge pull request #28 from candasm/develop
candasm Feb 9, 2017
540952d
Update code with psr-2 standards
candasm Feb 14, 2017
4cb9f34
Update travis-ci build.
candasm Feb 14, 2017
28f4717
Add licence.
candasm Feb 14, 2017
46223ac
Add contributing information.
candasm Feb 14, 2017
00845c3
Delete unnecessary docker.yml file.
candasm Feb 14, 2017
fe2d315
Add repository badges in to readme file.
candasm Feb 14, 2017
ab34e45
Add new version matrix to readme.md
candasm Feb 16, 2017
7405a29
Update composer.json for 4.0 version
candasm Feb 16, 2017
d1ab44b
Update readme file for new version matrix and information included on…
candasm Feb 16, 2017
d53135f
Update readme file with package version
candasm Feb 16, 2017
17403fb
Add logLevel option in elasticsearch config file.
candasm Feb 25, 2017
1f97f96
Update register method for elastic search 0.4 version.
candasm Feb 25, 2017
bed7b4b
Add Mockery and set autoload-dev for tests.
candasm Feb 25, 2017
d83f5e5
Remove tests folder from code sniffer
candasm Feb 25, 2017
a3f20fe
Update test suite name to unit.
candasm Feb 25, 2017
bb1fdef
Add unit tests for elastic search service provider and facade.
candasm Feb 25, 2017
2040b0c
Update new version matrix list.
candasm Feb 25, 2017
f7a5fcb
Update phpunit version to be compatible with PHP 5.4 version. Add php…
candasm Feb 26, 2017
e2cf6d1
Update travis build file and correct bin paths
candasm Feb 26, 2017
8d7bfd9
Update mockery mock class names for php 54.
candasm Feb 27, 2017
4589088
Merge pull request #31 from candasm/php_54_class_name_bug_fix
candasm Feb 27, 2017
df1214e
Add elastic search simple query test to create index. Update travis s…
candasm Feb 27, 2017
a7ee6c7
Merge pull request #32 from candasm/integration_tests
candasm Feb 27, 2017
79d368b
Update default config namespace name. Add integration tests path in p…
candasm Feb 27, 2017
818c97f
Merge pull request #33 from candasm/default_configuration_namespace_b…
candasm Feb 27, 2017
d1b9d01
Update readme file for 4.0 version.
candasm Feb 27, 2017
1860c34
Merge pull request #34 from candasm/4.0
candasm Feb 27, 2017
2e4f561
Update composer file with elastic search 1.0 version support. Update …
candasm Feb 27, 2017
dd16e91
Update elastic search version in travis config.
candasm Feb 27, 2017
5480e63
Update elastic search deb download path.
candasm Feb 27, 2017
c33a071
Change .travis.yml file for install elasticsearch 1.7
candasm Feb 27, 2017
4fbcdbc
Merge pull request #35 from candasm/version_4.1
candasm Feb 27, 2017
4ffe0ec
Update changes for elastic search 2.x versions. New config parameters…
candasm Feb 27, 2017
10c3a1f
Change config file to use with ClientBuilder::fromConfig method.
candasm Feb 27, 2017
e910cac
Merge pull request #36 from candasm/elasticsearch_2.x_updates
candasm Feb 27, 2017
a1bb2c4
Change branch alias tag in composer.json file.
candasm Feb 27, 2017
05fdcee
Merge pull request #37 from shift31/4.2
candasm Feb 27, 2017
10e04d5
Changes for elastic search 5.x.
candasm Feb 27, 2017
6f867ef
Update phpunit.xml file remove black list add white list.
candasm Feb 27, 2017
453b87e
Merge pull request #39 from candasm/elasticsearch_5.x_updates
candasm Feb 27, 2017
f1f840c
Update composer to not limit php support with php 7.1
candasm Mar 4, 2017
f6fd2f4
Make it compatible with Laravel 5 and php 7.3
j3j5 Dec 17, 2018
d2e7c8c
Make provider compatible with Laravel 5.x and add autodiscover
j3j5 Dec 17, 2018
975b353
support for laravel 6 and 7
jfoulquie-tnw Mar 5, 2020
d7f1e38
Create the logger on the service provider instead of on the config fi…
jfoulquie-tnw Mar 5, 2020
0dbdce1
Remove redundant deps that are provided by testbench
jfoulquie-tnw Oct 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/build
/vendor
composer.phar
composer.lock
.DS_Store
.idea
atlassian-ide-plugin.xml
composer.lock
29 changes: 22 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
language: php

php:
- 5.3
- 5.4
- 5.5
php:
- 5.6
- 7.0

addons:
apt:
sources:
- elasticsearch-5.0
packages:
- elasticsearch

services:
- elasticsearch

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:
- mkdir -p build/logs
- vendor/bin/phpcs
- vendor/bin/phpunit

script: phpunit
after_script:
- vendor/bin/coveralls -v
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]: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].
21 changes: 21 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -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.
80 changes: 43 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,66 @@
Elasticsearch for Laravel
=========================
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
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)
[![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/5.0/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.

| Elasticsearch Version | laravel-elasticsearch branch |
| --------------------- | ---------------------------- |
| >= 1.0 | 1.0, 2.0 |
| <= 0.90.* | 0.4 |

**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.
------------------
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.

|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 stable versions (which are created as a branch) and don't use dev-master branch!

Usage
-----
1. Run `composer require shift31/laravel-elasticsearch:~2.0`
1. Run `composer require shift31/laravel-elasticsearch:~4.5.0`

2. Create app/config/elasticsearch.php, modifying the following contents accordingly:
2. Publish config file

Laravel artisan command
```
$ php artisan config:publish shift31/laravel-elasticsearch
```
You can always read config parameters with:
```php
<?php

return array(
'hosts' => 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\ClientBuilder](https://github.com/elastic/elasticsearch-php/blob/5.0/src/Elasticsearch/ClientBuilder.php#L119).

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'`.

**If you are using Laravel 5.x**, add `'Shift31\LaravelElasticsearch\ElasticsearchServiceProvider'`. The ServiceProvider will enable the 'Es' facade for you.
3. In the `'providers'` array in app/config/app.php, add `'Shift31\LaravelElasticsearch\ElasticsearchServiceProvider'`.

4. Use the `Es` facade to access any method from the `Elasticsearch\Client` class, for example:
```php
$searchParams['index'] = 'your_index';
$searchParams['size'] = 50;
$searchParams['body']['query']['query_string']['query'] = 'foofield:barstring';

$result = Es::search($searchParams);
```

**A friendly reminder:** If you use the facade in a namespaced class (i.e. in a Laravel 5.x controller), you must add `use Es;` at the top of your file (after `<?php` of course), or add a backslash in front of any static calls (ex: `\Es::search(...)`).

Default Configuration
---------------------
If you return an empty array in the config file:
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.

`'hosts'` defaults to localhost:9200
[Default config file](src/config/elasticsearch.php) which is publishing by artisan command.

`'logPath'` defaults to `storage_path() . '/logs/elasticsearch.log'`
Contributing
---------------------
Please see [CONTRIBUTING.md](CONTRIBUTING.md).
71 changes: 46 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
{
"name": "shift31/laravel-elasticsearch",
"description": "A Laravel Service Provider for the Elasticsearch API client",
"authors": [
{
"name": "Shift 31 Consulting",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "~4|~5",
"elasticsearch/elasticsearch": "~2.0"
},
"autoload": {
"classmap": [
"src/migrations"
],
"psr-0": {
"Shift31\\LaravelElasticsearch": "src/"
}
"name": "shift31/laravel-elasticsearch",
"description": "A Laravel Service Provider for the Elasticsearch API client",
"authors": [
{
"name": "Shift 31 Consulting",
"email": "[email protected]"
}
],
"require": {
"php": ">=7.2",
"illuminate/support": "^6.0|^7.0|^8.0",
"elasticsearch/elasticsearch": "~5.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "^2.8",
"satooshi/php-coveralls": "^1.0",
"orchestra/testbench": "^4.0|^5.0|^6.0"
},
"autoload": {
"psr-0": {
"Shift31\\LaravelElasticsearch": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Shift31\\LaravelElasticsearch\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "4.5.x-dev"
},
"minimum-stability": "dev",
"prefer-stable": true,
"require-dev": {
"laravel/framework": "^5.2"
"laravel": {
"providers": [
"Shift31\\LaravelElasticsearch\\ElasticsearchServiceProvider"
],
"aliases": {
"Es": "Shift31\\LaravelElasticsearch\\Facades\\Es"
}
}
}
},
"scripts": {
"test": [
"vendor/bin/phpcs",
"vendor/bin/phpunit"
]
}
}
5 changes: 0 additions & 5 deletions docker-compose.yml

This file was deleted.

5 changes: 5 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="PSR2"/>
<file>./src</file>
</ruleset>
18 changes: 14 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
syntaxCheck="false">
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
<testsuite name="unit">
<directory suffix=".php">./tests/Unit</directory>
</testsuite>
<testsuite name="integration">
<directory suffix=".php">./tests/Integration</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/Shift31/LaravelElasticsearch</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
Empty file removed public/.gitkeep
Empty file.
Loading