How to use Meilisearch with Lando

How to use Meilisearch with Lando

I use Lando for all my PHP development environments. Working at a development agency means lots of different projects that all need different versions of software and Lando really solves that problem.

Meilisearch

Today I needed to add Meilisearch to an existing project and luckily Lando allows you to add your own custom services.

I initially found this online article which provided information on how to get Meilisearch working, however, it was not current and didn't work.

So I had to figure it out myself.

The Lando Config

Below is the config you will want to add to your .lando.yml file.

services:
  meilisearch:
    type: compose
    app_mount: false
    services:
      image: getmeili/meilisearch:v0.30
      command: tini -- /bin/sh -c /bin/meilisearch
      ports:
        - '7700'
      volumes:
        - meilisearch:/meili_data
    volumes:
      meilsearch:

Firstly, you'll notice this is locked to v0.30. This ensures the config will continue to run in the future, especially as Meilisearch's API is rapidly changing as signified by the zero major version.

We have specified port 7700 which is the standard Meilisearch port. However, to avoid conflicts we haven't specified an external port. To find the port being used you can run docker ps from the command line.

If you would like to specify the external port, perhaps because you only have one project running Meilisearch, you can change the config to:

      ports:
        - '7700:7700'

Meilisearch Mini-dashboard

Assuming you have your Lando project started (or rebuilt), you should be able to access Meilisearch's Mini-dashboard in your web browser.

If you set the external port manually to 7700 then you'll be able to use http://127.0.0.1:7700/

Otherwise, change the port to the one being used by Docker.

Laravel Scout Config

Add the following to your .env file.

SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://meilisearch:7700
MEILISEARCH_KEY=

Summary

Now you can start indexing your data and create an awesome fast search experience, how lovely.