PHPackages                             wangzd/laravel-elasticsearch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. wangzd/laravel-elasticsearch

ActiveLibrary[API Development](/categories/api)

wangzd/laravel-elasticsearch
============================

es

1.2.2(7y ago)312MITPHPPHP &gt;=7.0

Since Jan 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/wangzhoudong/laravel-elasticsearch)[ Packagist](https://packagist.org/packages/wangzd/laravel-elasticsearch)[ RSS](/packages/wangzd-laravel-elasticsearch/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (4)Versions (9)Used By (0)

laravel-elasticsearch
=====================

[](#laravel-elasticsearch)

### 介绍

[](#介绍)

为 [Laravel Scout](https://laravel-china.org/docs/laravel/5.5/scout/1346)开发的 [Elasticsearch](https://baijunyao.com/article/155) 驱动；

为了方便大家测试，搭建了一个带分词的elasticsearch docker

```
 docker run --name=es -p 9200:9200 -p 9300:9300 -d dongen/elasticsearch:latest

```

### 安装

[](#安装)

```
composer require wangzd/laravel-elasticsearch

```

2. Laravel 5.5 以下，`config/app.php` 中添加 `service provider`

```
'providers' => [

    // ...

    /**
     * Elasticsearch全文搜索
     */
    Wangzd\ScoutES\ESServiceProvider::class,
],
```

3.发布配置项;

```
```bash
php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"

```

4. 在 config/scout.php 添加配置

    ```
         'elasticsearch' => [
                'hosts' => [
                    env('ELASTICSEARCH_HOST', 'http://localhost'),
                ],
                'analyzer' => env('ELASTICSEARCH_ANALYZER', 'ik_max_word'),
                'settings' => [],
                'filter' => [
                ]
            ],

    ```

增加配置项；
.env ; ```bash

```
SCOUT_DRIVER=elasticsearch
SCOUT_PREFIX=local
#elasticsearch

ELASTICSEARCH_HOST=127.0.0.1:9200
ELASTICSEARCH_INDEX=shop_test

```

```

5 在你的Model里面引用 Searchable 如

```
namespace App\Models;

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

class ShopSearchModel extends Model
{
    use Searchable;
    /**
     * 数据表名
     */
    protected $table = "shop_search";

    /**
     * 主键
     */
    protected $primaryKey = "goods_id";
}

```

6. 执行全量索引创建 该操作会自动创建阿里云APP

```
  php artisan scout:import "App\Models\ShopSearchModel"

```

7.执行搜索

```
use App\Models\ShopSearchModel;

    Route::get('search', function () {
        // 为查看方便都转成数组
        dump(ShopSearchModel::search('搜索关键字')->get()->toArray());
    });
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity61

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

8

Last Release

2672d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4695837?v=4)[wangzd](/maintainers/wangzd)[@wangzd](https://github.com/wangzd)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wangzd-laravel-elasticsearch/health.svg)

```
[![Health](https://phpackages.com/badges/wangzd-laravel-elasticsearch/health.svg)](https://phpackages.com/packages/wangzd-laravel-elasticsearch)
```

###  Alternatives

[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[jeroen-g/explorer

Next-gen Elasticsearch driver for Laravel Scout.

397612.3k](/packages/jeroen-g-explorer)[shift31/laravel-elasticsearch

A Laravel Service Provider for the Elasticsearch API client

201369.7k1](/packages/shift31-laravel-elasticsearch)[handcraftedinthealps/elasticsearch-dsl

Elasticsearch DSL library

212.5M14](/packages/handcraftedinthealps-elasticsearch-dsl)[m6web/elasticsearch-bundle

Symfony2 Bundle on top of elasticsearch/elasticsearch-php

22631.8k2](/packages/m6web-elasticsearch-bundle)[james2doyle/laravel-scout-sonic

Sonic driver for Laravel Scout.

543.0k](/packages/james2doyle-laravel-scout-sonic)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
