Skip to main content
Algolia Scout Extended requires the following PHP and Laravel versions:
Scout Extended versionPHP versionLaravel version
38.1 and later10 and later
8.0 and later9 and later
27.3 and later8 and later
17.3 and later6
For more information, read the Scout Extended changelog.
  1. Install Scout Extended with Composer:
    # Install the latest version of Scout Extended
    composer require "algolia/scout-extended:^3.0"
    
  2. Publish the Scout configuration to your config directory:
    php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
    
  3. For the model you would like to make searchable, add the Searchable trait. For example, for an Article model (app/Models/Article.php):
    PHP
    namespace App\Models;
    
    use Laravel\Scout\Searchable;
    use Illuminate\Database\Eloquent\Model;
    
    class Article extends Model
    {
        use Searchable;
    }
    
    Replace Article with a model used in your app.
  4. While not required, you should use a queue driver for Scout operations. After configuring a queue driver, set queue to true in your config/scout.php file:
    PHP
    'queue' => true,
    
  5. To access Algolia, copy your credentials from the Algolia dashboard to your .env file:
    ALGOLIA_APP_ID=<ALGOLIA_APP_ID>
    ALGOLIA_SECRET=<ALGOLIA_API_KEY>
    
    • <ALGOLIA_APP_ID>. Your Algolia application ID.
    • <ALGOLIA_API_KEY>. Your API key with search and addObject permissions.
  6. To import existing data:
    • If you’re importing from your Laravel database for the first time, use scout:import.
    • If you’ve installed Scout Extended in a Laravel Scout project, use scout:reimport.
    If you make significant changes to your Scout configuration or need to reindex all your data, use scout:reimport to ensure everything is in sync.
  7. Open the routes/web.php file and add the following route to the bottom of the file:
    PHP
    Route::get('search', function() {
        $query = ''; // <-- Change the query for testing.
        // Visit the /search route in your web browser to see articles that match the test $query.
    
        $articles = App\Article::search($query)->get();
    
        return $articles;
    });
    
    Replace Article with a model used in your app.
I