PHPackages                             setono/sylius-meilisearch-plugin - 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. [Search &amp; Filtering](/categories/search)
4. /
5. setono/sylius-meilisearch-plugin

ActiveSylius-plugin[Search &amp; Filtering](/categories/search)

setono/sylius-meilisearch-plugin
================================

Meilisearch integration for your Sylius store

37594[13 issues](https://github.com/Setono/sylius-meilisearch-plugin/issues)[4 PRs](https://github.com/Setono/sylius-meilisearch-plugin/pulls)PHPCI passing

Since Feb 11Pushed 1mo ago5 watchersCompare

[ Source](https://github.com/Setono/sylius-meilisearch-plugin)[ Packagist](https://packagist.org/packages/setono/sylius-meilisearch-plugin)[ RSS](/packages/setono-sylius-meilisearch-plugin/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (7)Used By (0)

Meilisearch Plugin for Sylius
=============================

[](#meilisearch-plugin-for-sylius)

[![Latest Version](https://camo.githubusercontent.com/eaa759fed4674ca6f1dc911e7ffbdb46c80c01431598e0c15f10957685c41768/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f73796c6975732d6d65696c697365617263682d706c7567696e2f762f737461626c65)](https://packagist.org/packages/setono/sylius-meilisearch-plugin)[![Software License](https://camo.githubusercontent.com/9bf05add4e22cbb98645ce289ba96e4a92b711bf1ce160af2c16bc3225d70a68/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f73796c6975732d6d65696c697365617263682d706c7567696e2f6c6963656e7365)](LICENSE)[![Build Status](https://github.com/Setono/sylius-meilisearch-plugin/workflows/build/badge.svg)](https://github.com/Setono/sylius-meilisearch-plugin/actions)[![Code Coverage](https://camo.githubusercontent.com/dc2c7b0f6626d990d0ba16e413fe9399449496f94e6159b3b8b2225d6b2a2cfe/68747470733a2f2f636f6465636f762e696f2f67682f5365746f6e6f2f73796c6975732d6d65696c697365617263682d706c7567696e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Setono/sylius-meilisearch-plugin)

Integrate [Meilisearch](https://www.meilisearch.com/) — the lightning-fast, open-source search engine — into your [Sylius](https://sylius.com/) store.

Features
--------

[](#features)

- **Automatic indexing** — entities are indexed when they change (via Doctrine lifecycle events) and can be (re)indexed in bulk with a console command
- **Search page** — a ready-made, faceted search experience for your shop, including taxon pages backed by Meilisearch
- **Autocomplete** — an instant-search widget powered by Meilisearch's official autocomplete library
- **Facets &amp; filters** — declare facets, filters, and sortable fields with PHP attributes on a plain document class
- **Synonyms** — manage search synonyms in the Sylius admin; they are synced to Meilisearch automatically
- **Extensible by design** — data mappers, URL generators, entity filters, index scopes, and facet sorters are all pluggable services

Requirements
------------

[](#requirements)

- PHP `>= 8.1`
- Sylius `1.14` on Symfony `6.4` (the versions the plugin is built and tested against)
- A running Meilisearch instance

Installation
------------

[](#installation)

### 1. Require the plugin

[](#1-require-the-plugin)

```
composer require setono/sylius-meilisearch-plugin
```

### 2. Register the plugin

[](#2-register-the-plugin)

> **No Symfony Flex recipe ships yet** ([\#74](https://github.com/Setono/sylius-meilisearch-plugin/issues/74) tracks adding one), so every step in this installation guide is manual — Flex will not register the bundle, configure it, or import the routing for you.

Add the plugin to your `config/bundles.php` before `SyliusGridBundle`:

```
Setono\SyliusMeilisearchPlugin\SetonoSyliusMeilisearchPlugin::class => ['all' => true],
```

### 3. Configure the plugin

[](#3-configure-the-plugin)

```
# config/packages/setono_sylius_meilisearch.yaml
setono_sylius_meilisearch:
    indexes:
        products:
            document: 'Setono\SyliusMeilisearchPlugin\Document\Product'
            entities: [ 'App\Entity\Product\Product' ]
    search:
        enabled: true
        index: products
```

Add your Meilisearch credentials to `.env.local`:

```
###> setono/sylius-meilisearch-plugin ###
MEILISEARCH_URL=http://localhost:7700       # required; server-side URL the PHP SDK connects to
MEILISEARCH_MASTER_KEY=YOUR_MASTER_KEY       # required; used for indexing and settings
MEILISEARCH_SEARCH_KEY=YOUR_SEARCH_KEY       # required for search/autocomplete (search-only key)
MEILISEARCH_PUBLIC_URL=                       # optional; browser-facing URL for the autocomplete widget when MEILISEARCH_URL is an internal hostname. Falls back to MEILISEARCH_URL when empty
MEILISEARCH_PREFIX=                           # optional; useful when developers share a Meilisearch instance
###< setono/sylius-meilisearch-plugin ###
```

Index names are automatically prefixed with the kernel environment (and your optional `MEILISEARCH_PREFIX`), so `dev`, `test`, and `prod` never collide.

The full list of options is always available via:

```
php bin/console config:dump-reference setono_sylius_meilisearch
```

### 4. Import routing

[](#4-import-routing)

```
# config/routes/setono_sylius_meilisearch.yaml
setono_sylius_meilisearch:
    resource: "@SetonoSyliusMeilisearchPlugin/Resources/config/routes.yaml"
```

or if your app doesn't use locales:

```
# config/routes/setono_sylius_meilisearch.yaml
setono_sylius_meilisearch:
    resource: "@SetonoSyliusMeilisearchPlugin/Resources/config/routes_no_locale.yaml"
```

This registers the shop search page (`/search`), the taxon search page (`/taxons/{slug}`), the search widget endpoint, and the synonym CRUD in the admin.

### 5. Implement `IndexableInterface` in your entities

[](#5-implement-indexableinterface-in-your-entities)

Every entity you index must implement `Setono\SyliusMeilisearchPlugin\Model\IndexableInterface`. The `IndexableAwareTrait` provides a default implementation that uses the entity id as the document identifier:

```
