meilisearch / meilisearch-laravel-scout

Laravel Scout custom engine for MeiliSearch


MeiliSearch Laravel Scout

MeiliSearch Laravel Scout

MeiliSearch | Website | Blog | Twitter | Documentation | FAQ

Latest Stable Version Actions Status License Slack

Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine MeiliSearch driver for Laravel Scout

MeiliSearch Laravel Scout is a MeiliSearch driver for Laravel. MeiliSearch is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, and synonyms are provided out-of-the-box.

Table of Contents



$ composer require meilisearch/meilisearch-laravel-scout

Export configuration

$ php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
$ php artisan vendor:publish --provider="Meilisearch\Scout\MeilisearchServiceProvider" --tag="config"

Update .env


Run MeiliSearch

There are many easy ways to download and run a MeiliSearch instance.

For example, if you use Docker:

$ docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey

NB: you can also download MeiliSearch from Homebrew or APT.

Getting started


Create an index

// Create an index
$ php artisan scout:index books
// Create an index and give the primary-key
$ php artisan scout:index books --key book_id

Add document


use Laravel\Scout\Searchable;

class Book extends Model
    use Searchable;

class BookController extends Controller
    public function store()
        $book = new Book();
        $book->title = 'Pride and Prejudice';

You can also import all your table to meilisearch by using the artisan command:

$ php artisan scout:import "App\Book"

Search in index

class BookController extends Controller
    public function search()
        // MeiliSearch is typo-tolerant:
        Book::search('harry pottre')->get();
        // Or if you want to get the result from meilisearch:
        Book::search('harry pottre')->raw();

Delete documents

class BookController extends Controller
    public function destroy($id)
        // Delete one document
        // Delete several documents
        Book::destroy([1, 42]);
        // Delete all documents /!\

or you can use the artisan command to delete all documents from an index:

$ php artisan scout:flush "App\Book"

Delete an index

$ php artisan scout:index -d books


Custom search

All the supported options are described in this documentation section.

class BookController extends Controller
    public function customSearch()
        Book::search('prince', function (Index $meilisearch, $query, $options) {
            $options['filters'] = 'author="Antoine de Saint-Exupéry"';

            return $meilisearch->search($query, $options);


class BookController extends Controller
    public function search()
        // with a limit of items per page:
        // using meilisearch response:

Compatibility with MeiliSearch

This package is compatible with the following MeiliSearch versions:

  • v0.10.X

Development Workflow

If you want to contribute, this section describes the steps to follow.

Thank you for your interest in a MeiliSearch tool! ♥️

Install dependencies

$ composer install

Tests and Linter

Each PR should pass the tests to be accepted.

$ vendor/bin/phpunit --color tests/


MeiliSearch tools follow the Semantic Versioning Convention.

Once the changes are merged into master, you must create a release (with this name vX.X.X) via the GitHub interface.

A webhook will be triggered and push the new package on Packagist.

Additional notes

You can use more advance function by reading the documentation of MeiliSearch PHP Client

This package is a custom engine of Laravel Scout

MeiliSearch provides and maintains many SDKs and Integration tools like this one. We want to provide everyone with an amazing search experience for any kind of project. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the integration-guides repository.