There is no license information available for the latest version (4.0.0) of this package.

Elastic Driver for Laravel Scout (with AWS IAM capability)

4.0.0 2018-07-01 17:46 UTC


Software License

This package makes is the Elasticsearch driver for Laravel Scout that works with AWS' Elasticsearch and does not require you to put credentials into .env files.



You can install the package via composer:

composer require tamayo/laravel-scout-elastic

You must add the Scout service provider and the package service provider in your app.php config:

// config/app.php
'providers' => [


This package assumes you are following good AWS security and /not/ putting password in your Laravel .env files an instead follows the practices outlined in Credentials for the AWS SDK for PHP Version 3. To enable this, set the following variable in your .env.


For local development, inside vagrant for instance, you can use the normal Elasticsearch client by either omitting this variable or setting it as follows.


One thing the AWS client needs is the Region. If you don't already have it in your .env, add it as such.


Testing with Scout

If your CI environment does not have access to a working Elasticsearch instance, any indexed Models will cause it to error. To solve this, add the following to your phpunit.xml. The single quotes wrapping the double quotes are the tricky part there.

<env name="SCOUT_DRIVER" value='"null"' />

Laravel Configuration

After you've published the Laravel Scout package configuration

php artisan vendor:publish  --provider="ScoutEngines\Elasticsearch\ElasticsearchProvider"

you'll need to update the main scout configuration

// config/scout.php
// Set your driver to elasticsearch
    'driver' => env('SCOUT_DRIVER', 'elasticsearch'),

    'elasticsearch' => [
        'index' => env('ELASTICSEARCH_INDEX', 'laravel'),
        'hosts' => [
            env('ELASTICSEARCH_HOST', 'http://localhost'),

and this package's configuration

// config/laravel-scout-elastic
// set this if you don't want to include it in your .env
    'provider' => env('ELASTICSEARCH_PROVIDER', 'elasticsearch'),
    'region' => env('AWS_REGION', 'us-west-2'),

and enable the artisan job:

// App/Console/Kernel.php
protected $commands = [

Elasticsearch Configuration

Scout will happily throw an error if it cannot create contact your Elasticsearch server or the index doesn't exist.

Creating an index can be kinda arcane, so if the index doesn't exist, you can include the following artisan command in your deployment stack to check if the index exists, and if it doesnt then it will create it.

php artisan scout:create-index


Now you can use Laravel Scout as described in the official documentation



The MIT License (MIT).