|
1 | 1 | # laravel-elastic-sessions |
2 | | -A session driver for elastic search for laravel 5.1 |
| 2 | +An elastic-search based session driver for Laravel 5.1 |
| 3 | + |
| 4 | +##How to use |
| 5 | + 1. Require it via composer |
| 6 | + ``` |
| 7 | + composer require itvisionsy/laravel-elastic-sessions |
| 8 | + ``` |
| 9 | + 2. Add it to the providers list in `config/app.php`: |
| 10 | + ```php |
| 11 | + 'providers' => [ |
| 12 | + //... |
| 13 | + ItvisionSy\LaravelElasticSessionDriver\ElasticSessionServiceProvider::class, |
| 14 | + //... |
| 15 | + ] |
| 16 | + ``` |
| 17 | + 3. Set the correct settings in `config/session.php` |
| 18 | + ```php |
| 19 | + "driver" => "elastic", |
| 20 | + "elastic" => [ |
| 21 | + "url" => "http://localhost:9200/", |
| 22 | + "index" => "laravel-es-sessions", |
| 23 | + "type" => "session" |
| 24 | + ], |
| 25 | + ``` |
| 26 | + Values shown above are the default values in case you did not configure. |
| 27 | +
|
| 28 | +###Index/Type mapping |
| 29 | +Elastic will detect the mapping by default, however, it is recommended to set the mapping explicitly. |
| 30 | +
|
| 31 | +You can do so manually by applying this mapping to the index and type: |
| 32 | +```json |
| 33 | +{ |
| 34 | + "index":"set_the_index", |
| 35 | + "type":"set_the_type", |
| 36 | + "body":{ |
| 37 | + "properties":{ |
| 38 | + "created":{"type":"date"}, |
| 39 | + "updated":{"type":"date"}, |
| 40 | + "data":{"type":"string","index":"no"} |
| 41 | + } |
| 42 | + } |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +Or simpler, the package can do it for you. You will need to tinker `./artisan tinker` and then set the mapping: |
| 47 | +```php |
| 48 | +\ItvisionSy\LaravelElasticSessionDriver\ElasticSessionStore::putMapping(); |
| 49 | +``` |
| 50 | + |
| 51 | +## Author |
| 52 | +Muhannad Shelleh <muhannad.shelleh@live.com> |
| 53 | + |
| 54 | +## License |
| 55 | +This code is published under [MIT](LICENSE) license. |
0 commit comments