作用:搜索驱动,可随时更换驱动,上层业务逻辑可不用改变
官网文档:https://laravel-china.org/docs/laravel/5.4/scout/1276
首先,使用 composer 包管理器来安装 Scout:
composer require laravel/scout
接下来,你需要将 ScoutServiceProvider 添加到你的 config/app.php 配置文件的 providers 数组中:
Laravel\Scout\ScoutServiceProvider::class,
注册好 Scout 的服务提供者之后,你可以使用 vendor:publish Artisan 命令生成 Scout 的配置文件。这个命令会在你的 config 目录下生成 scout.php 配置文件:
php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
Git文档:https://github.com/ErickTamayo/laravel-scout-elastic
You can install the package via composer:
composer require tamayo/laravel-scout-elastic
注:在安装tamayo/laravel-scout-elastic时,一直报错无法正常安装,可参考安装scount的es驱动,composer require tamayo/laravel-scout-elastic报错解决
截图中重新安装了laravel/scout 5.0.3版本后再安装tamayo/laravel-scout-elastic的截图
You must add the Scout service provider and the package service provider in your config/app.php config:
‘providers‘ => [ ... Laravel\Scout\ScoutServiceProvider::class, ... ScoutEngines\Elasticsearch\ElasticsearchProvider::class, ],
Setting up Elasticsearch configuration
// config/scout.php // Set your driver to elasticsearch ‘driver‘ => env(‘SCOUT_DRIVER‘, ‘elasticsearch‘), ...
‘elasticsearch‘ => [
‘index‘ => env(‘ELASTICSEARCH_INDEX‘, ‘laravel54‘),
‘hosts‘ => [
env(‘ELASTICSEARCH_HOST‘, ‘http://127.0.0.1:9200‘),
],
]
...
原文:https://www.cnblogs.com/wanghaokun/p/10096315.html