Skip to main content
Algolia Scout Extended connects your Laravel models to Algolia. It builds on Laravel Scout and keeps your Algolia index in sync when you create, update, or delete records. Its source code is open source under the MIT license.

Before you begin

You need: These requirements are for Scout Extended v5. To upgrade from an earlier version, see the Upgrade guide.

Set up the package

Set up the package in a new Laravel app. Then index and search a record.
1

Create a Laravel app

To create a new Laravel app, run:
2

Install Scout Extended

To add Scout Extended to your composer.json file and install it, run:
To publish the Scout configuration to your config directory, run:
3

Add your credentials

To set Algolia as the Scout driver, add the following lines to your .env file:
.env
Replace ALGOLIA_APPLICATION_ID and ALGOLIA_API_KEY with your Algolia credentials. Find both in the Algolia dashboard. To run this test, use an API key with the search and addObject ACL.
To create Algolia applications and API keys from the command line, use the Algolia CLI.
4

Create a model

To create a Contact model and its migration, run:
In the migration file in database/migrations, add a name column to the contacts table:
PHP
To create the database table, run:
5

Connect the model to Algolia

To send your model to Algolia, add the Searchable trait. Scout Extended stores the model’s records in an named after its table, contacts.Replace the contents of app/Models/Contact.php:
app/Models/Contact.php
6

Index and search a record

To add a record, run:
Algolia indexes records asynchronously, so wait 5 seconds. Then, to search for the record, run:
If the setup works, the command prints ["Jon Doe"]. Each run of the first command adds another record to your test index. To remove the test data, delete the index in the Algolia dashboard or with the Algolia CLI.

Use a queue driver

Optional: to run Scout operations in the background, configure a queue driver. Then, in your config/scout.php file, set queue to true:
PHP

Import existing data

Choose scout:import or scout:reimport to import your existing data:
  • For a new index or an index without live traffic, use scout:import. This command clears any existing records in the index before importing.
  • If your existing Laravel Scout project has an Algolia index that serves live traffic, use scout:reimport to keep search available while you rebuild the index, for example after a significant Scout configuration change.
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. Scout Extended’s Artisan commands manage index settings and copy, move, and delete indices. To run them, use an API key with the search, browse, addObject, deleteObject, deleteIndex, editSettings, and settings ACL.

Next steps

Last modified on November 27, 2026