Skip to content

Commit

Permalink
update for Laravel 5.5, consolidate Lumen files
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin Viebrock committed Aug 31, 2017
1 parent d5045bc commit 0bdb58e
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 287 deletions.
16 changes: 13 additions & 3 deletions .travis.yml
Expand Up @@ -3,9 +3,19 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- 7.2

env:
- COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
- COMPOSER_FLAGS=""

matrix:
exclude:
- php: 7.2
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"

before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install --dev
- travis_retry composer self-update
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog

## 2.1.0 - 31-Aug-2017

- Laravel 5.5 support, including auto-registration
- Bump ES client version to ^5.3


## 2.0.1 - 14-Jul-2017

* Add alias for Lumen (thanks @matejvelikonja)
Expand Down
39 changes: 11 additions & 28 deletions README.md
Expand Up @@ -19,36 +19,24 @@ An easy way to use the [official Elastic Search client](https://github.com/elast

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

```shell
```sh
composer require cviebrock/laravel-elasticsearch
```

### Laravel
### Laravel

Add the service provider and facade to `config/app.php`:

```php
'providers' => [
...
Cviebrock\LaravelElasticsearch\ServiceProvider::class,
]

'aliases' => [
...
'Elasticsearch' => Cviebrock\LaravelElasticsearch\Facade::class,
]
```
The package will automatically register itself.

Publish the configuration file:

```shell
```sh
php artisan vendor:publish --provider="Cviebrock\LaravelElasticsearch\ServiceProvider"
```

##### Alternative configuration method via .env file

After you publish the configuration file as suggested above, you may configure Elastic Search
by adding the following to laravel `.env` file
by adding the following to your application's `.env` file (with appropriate values):

```ini
ELASTICSEARCH_HOST=localhost
Expand All @@ -60,20 +48,15 @@ ELASTICSEARCH_PASS=

### Lumen

If you work with Lumen, please register the LumenServiceProvider in `bootstrap/app.php`:

```php
$app->register(Cviebrock\LaravelElasticsearch\LumenServiceProvider::class);
```

And manually copy the configuration file to your application.

**Note:** don't forget to register your elasticsearch.php config in bootstrap/app.php
If you work with Lumen, please register the service provider and configuration in `bootstrap/app.php`:

```php
$app->register(Cviebrock\LaravelElasticsearch\ServiceProvider::class);
$app->configure('elasticsearch');
```

Manually copy the configuration file to your application.



## Usage
Expand Down Expand Up @@ -114,7 +97,7 @@ in order to get the ES service object:

```php
// using injection:
public function handle(\Cviebrock\LaravelElasticsearch\LumenManager $elasticsearch)
public function handle(\Cviebrock\LaravelElasticsearch\Manager $elasticsearch)
{
$elasticsearch->ping();
}
Expand All @@ -123,7 +106,7 @@ public function handle(\Cviebrock\LaravelElasticsearch\LumenManager $elasticsear
$elasticSearch = $this->app('elasticsearch');
```

(Of course, DI and the application container work for Laravel as well.)
Of course, DI and the application container work for Laravel as well.


## Bugs, Suggestions and Contributions
Expand Down
4 changes: 2 additions & 2 deletions TODO.md
@@ -1,5 +1,5 @@
# To-do List
# Todos

- [ ] Tests!
- [ ] More documentation
- [ ] Allow for client "wrappers" that add functionality to the client (e.g., automatic index prefixing/suffixing, index templates configuration, etc.)
- [ ] Tests!
76 changes: 38 additions & 38 deletions composer.json
@@ -1,40 +1,40 @@
{
"name": "cviebrock/laravel-elasticsearch",
"description": "An easy way to use the official PHP ElasticSearch client in your Laravel applications.",
"keywords": [
"laravel",
"elasticsearch",
"search",
"client"
],
"require": {
"php": ">=5.4.0",
"elasticsearch/elasticsearch": "^5.0",
"illuminate/support": "~5",
"monolog/monolog": "~1"
},
"license": "MIT",
"authors": [
{
"name": "Colin Viebrock",
"email": "colin@viebrock.ca"
}
],
"autoload": {
"psr-4": {
"Cviebrock\\LaravelElasticsearch\\": "src/"
}
},
"minimum-stability": "stable",
"prefer-stable": true,
"extra": {
"laravel": {
"providers": [
"Cviebrock\\LaravelElasticsearch\\ServiceProvider"
],
"aliases": {
"Elasticsearch": "Cviebrock\\LaravelElasticsearch\\Facade"
}
}
}
"name": "cviebrock/laravel-elasticsearch",
"description": "An easy way to use the official PHP ElasticSearch client in your Laravel applications.",
"keywords": [
"laravel",
"elasticsearch",
"search",
"client"
],
"require": {
"php": "^7.0",
"elasticsearch/elasticsearch": "^5.3",
"illuminate/support": "~5.5.0",
"monolog/monolog": "^1.23"
},
"license": "MIT",
"authors": [
{
"name": "Colin Viebrock",
"email": "colin@viebrock.ca"
}
],
"autoload": {
"psr-4": {
"Cviebrock\\LaravelElasticsearch\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Cviebrock\\LaravelElasticsearch\\ServiceProvider"
],
"aliases": {
"Elasticsearch": "Cviebrock\\LaravelElasticsearch\\Facade"
}
}
},
"minimum-stability": "stable",
"prefer-stable": true
}
4 changes: 1 addition & 3 deletions src/Facade.php
Expand Up @@ -12,9 +12,7 @@ class Facade extends BaseFacade
{

/**
* Get the registered name of the component.
*
* @return string
* @inheritdoc
*/
protected static function getFacadeAccessor()
{
Expand Down
5 changes: 4 additions & 1 deletion src/Factory.php
@@ -1,5 +1,6 @@
<?php namespace Cviebrock\LaravelElasticsearch;

use Elasticsearch\Client;
use Elasticsearch\ClientBuilder;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -29,6 +30,7 @@ class Factory
* the default client.
*
* @param array $config
*
* @return \Elasticsearch\Client|mixed
*/
public function make(array $config)
Expand All @@ -41,9 +43,10 @@ public function make(array $config)
* Build and configure an Elasticsearch client.
*
* @param array $config
*
* @return \Elasticsearch\Client
*/
protected function buildClient(array $config)
protected function buildClient(array $config): Client
{

$clientBuilder = ClientBuilder::create();
Expand Down
135 changes: 0 additions & 135 deletions src/LumenManager.php

This file was deleted.

0 comments on commit 0bdb58e

Please sign in to comment.