Thinley Koblensky
Thinley Koblensky

Reputation: 156

How to Install laravel/scout on Lumen with mysql driver?

Steps to install laravel/scout on Lumen framework (there are some additional steps that you need to do to make it work with lumen opposed to Laravel)

Upvotes: 1

Views: 1358

Answers (2)

AmirHossein AshariNik
AmirHossein AshariNik

Reputation: 26

According to the above answer,this line: 'driver' => env('SCOUT_DRIVER', 'mysql'), cause an error which was "Driver [mysql] not supported".

For solving the problem use "database" instead of "mysql" as a driver.

Upvotes: 0

Thinley Koblensky
Thinley Koblensky

Reputation: 156

First install laravel

composer require laravel/scout

Register the service provider in the bootstrap/app.php in the provider section

$app->register(Laravel\Scout\ScoutServiceProvider::class);

Copy the configuration file (you may be able to do it with composer php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider" , I wasn't)

cp vendor/laravel/scout/config/scout.php config/scout.php

Ask lumen to load the configuration file, adding this line to boostrap/app.php

$app->configure('scout');

Install laravel mysql mysql driver

composer require yab/laravel-scout-mysql-driver

Change the driver setting in config/scout.php

'driver' => env('SCOUT_DRIVER', 'mysql'),

Append this to config/scout.php

 'mysql' => [
        'mode' => 'NATURAL_LANGUAGE',
        'model_directories' => [app_path()],
        'min_search_length' => 0,
        'min_fulltext_search_length' => 4,
        'min_fulltext_search_fallback' => 'LIKE',
        'query_expansion' => false
    ]

run the scout index if plan to use in NATURAL_LANGUAGE or BOOLEAN

php artisan scout:mysql-index

Use like this

Model::search(searchString)->get();

You can also add other conditions

Model::search(searchString)->where(...)->get()

Upvotes: 5

Related Questions