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