> ## Documentation Index
> Fetch the complete documentation index at: https://www.algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Learn how to install Algolia Scout Extended.

[Algolia Scout Extended](/doc/framework-integration/laravel/getting-started/introduction-to-scout-extended) requires the following PHP and Laravel versions:

| Scout Extended version | PHP version | Laravel version |
| - | - | - |
| 5 | 8.1 and later | 10 and later |
| 4 | 8.1 and later | 10 and later |
| 3 | 8.1 and later | 10 and later |
| 3 | 8.0 and later | 9 and later |
| 2 | 7.3 and later | 8 and later |
| 1 | 7.3 and later | 6 |

<Note>
  Scout Extended v4 upgrades Algolia's PHP API client to v4 and requires Laravel Scout 10.11.6 or later.
  Scout Extended v5 requires Laravel Scout 11,
  which replaces the `numericFilters` search parameter with `filters`.
  To upgrade from an earlier version, see the [Upgrade guide](/doc/framework-integration/laravel/getting-started/upgrade-guide).
</Note>

<Info>
  For more information, read the [Scout Extended changelog](https://github.com/algolia/scout-extended/blob/master/CHANGELOG.md).
</Info>

1. Install Scout Extended with Composer:

   ```sh Command line icon=square-terminal theme={"system"}
   # Install the latest version of Scout Extended
   composer require "algolia/scout-extended:^5.0"
   ```

2. Publish the Scout configuration to your `config` directory:

   ```sh Command line icon=square-terminal theme={"system"}
   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 PHP icon=code theme={"system"}
   namespace App\Models;

   use Laravel\Scout\Searchable;
   use Illuminate\Database\Eloquent\Model;

   class Article extends Model
   {
       use Searchable;
   }
   ```

   <Check>Replace `Article` with a model used in your app.</Check>

4. Optional: use a [queue driver](https://laravel.com/docs/queues) for Scout operations.
   After configuring a queue driver, set `queue` to `true` in your `config/scout.php` file:

   ```php PHP icon=code theme={"system"}
   'queue' => true,
   ```

5. Set Algolia as the Scout driver and copy your credentials from the [Algolia dashboard](https://dashboard.algolia.com/account/api-keys/) to your [`.env` file](https://laravel.com/docs/configuration#environment-configuration):

   ```dotenv .env icon=lock-keyhole theme={"system"}
   SCOUT_DRIVER=algolia
   ALGOLIA_APP_ID=# Your Algolia application ID
   ALGOLIA_SECRET=# Your Algolia admin API key
   ```

   <Note>
     Laravel Scout defaults to the `collection` driver,
     so you must set `SCOUT_DRIVER=algolia` for your data to be indexed in Algolia.
     Scout Extended's Artisan commands manage index settings and copy, move, and delete indices,
     so `ALGOLIA_SECRET` requires the admin API key
     (or a key with the `search`, `browse`, `addObject`, `deleteObject`, `deleteIndex`, `editSettings`, and `settings` permissions).
   </Note>

6. To import existing data:

   * If you're importing from your Laravel database for the first time, [use `scout:import`](/doc/framework-integration/laravel/indexing/import-into-algolia).
   * If you've installed Scout Extended in a Laravel Scout project, [use `scout:reimport`](/doc/framework-integration/laravel/production/zero-downtime-reimports).

   <Note>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.</Note>

7. Open the `routes/web.php` file and add the following route to the bottom of the file:

   ```php PHP icon=code theme={"system"}
   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\Models\Article::search($query)->get();

       return $articles;
   });
   ```

   <Check>Replace `Article` with a model used in your app.</Check>
