Integrating Meilisearch With Laravel Using Docker

Laravel Meilisearch Docker Integrating Laravel & Meilisearch
Profile Picture Joton Sutradhar โ€ข ๐Ÿ“– 3 min read โ€ข ๐Ÿ“… 26th May 2025

Heads up!

Check my blogs on Dev.to and Medium!
Register Now Icon

Write Your Story Today

Join the creator community. Start writing blogs and share your knowledge with the world.

If you're building a Laravel application and want blazing-fast search capabilities, Meilisearch is one of the best tools you can integrate. In this post, we’ll explore what Meilisearch is, why you should consider it, its use cases, pros and cons, and how to integrate it into a Laravel project using Docker.

๐Ÿง  What is Meilisearch?

Meilisearch is an open-source, lightning-fast search engine designed for modern web apps. Written in Rust, it provides out-of-the-box full-text search with typo tolerance, customizable ranking, filters, and near-instant results.

It’s ideal for applications where quick and relevant results are key to the user experience.

๐Ÿค” Why Meilisearch?

So, why choose Meilisearch over other tools like Algolia or Elasticsearch?

  • Developer-friendly: Meilisearch has a simple, RESTful API and integrates beautifully with Laravel using Laravel Scout.

  • Blazing fast: Search results are returned in milliseconds, providing an instant feel to your UI.

  • Zero-config startup: With Docker, you can be running in less than a minute.

  • Built-in features like typo tolerance, ranking, filtering, and synonyms with little to no setup.

  • Self-hosted alternative to Algolia: No API rate limits or high costs.

  • Great for user-facing search: Tailored for applications that require fast, fuzzy search with good UX.

๐Ÿ›  Uses of Meilisearch

Meilisearch is ideal for:

  • E-commerce platforms: Search products by name, category, brand, etc.

  • Blogs & content systems: Instant article and tag search.

  • CRMs & dashboards: Quick filtering across tables.

  • Directories & job boards: Faceted search and filters across multiple fields.

  • Any Laravel app that benefits from fast search.

โœ… Pros and โŒ Cons of Meilisearch

โœ… Pros:

  • Extremely fast and lightweight

  • Easy to set up and scale

  • Built-in typo tolerance and filters

  • Instant indexing

  • RESTful and easy API

  • Self-hosted and free

โŒ Cons:

  • Uses in-memory indexing (can be memory-intensive for very large datasets)

  • Not suitable for complex analytics-heavy queries

  • Still growing in community and ecosystem

  • No official horizontal sharding yet (in development)

๐Ÿณ Integrating Meilisearch with Laravel Using Docker

Step 1: Docker Compose for Laravel + Meilisearch

Create a docker-compose.yml file that includes both the Laravel app and Meilisearch service in the same network:

version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    image: laravel-app
    container_name: laravel-app
    restart: unless-stopped
    ports:
      - "8000:8000"
    volumes:
      - .:/var/www
    depends_on:
      - meilisearch
    networks:
      - laravel

  meilisearch:
    image: getmeili/meilisearch:v1.8
    container_name: meilisearch
    environment:
      - MEILI_MASTER_KEY=masterKey
    ports:
      - "7700:7700"
    volumes:
      - ./meili_data:/meili_data
    networks:
      - laravel

networks:
  laravel:
    driver: bridge

โš ๏ธ Make sure your Laravel .env points to http://meilisearch:7700 (Docker container name) instead of localhost.

Step 2: Install Laravel Scout & Meilisearch PHP SDK

Run:

composer require laravel/scout meilisearch/meilisearch-php

Then publish the config:

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

Step 3: Configure .env and config/scout.php

Update your .env:

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

In config/scout.php, set:

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

Step 4: Make a Model Searchable

Add the Searchable trait to your model:

use Laravel\Scout\Searchable;

class Post extends Model
{
    use Searchable;

    public function toSearchableArray(): array
    {
        return [
            'title' => $this->title,
            'body' => $this->body,
        ];
    }
}

Step 5: Import Data

php artisan scout:import "App\Models\Post"

Step 6: Perform a Search

$results = Post::search('Laravel')->get();

๐Ÿงช Final Thoughts

Meilisearch brings performance and simplicity to Laravel search like never before. With features like typo tolerance and instant results, it's perfect for modern apps needing real-time, full-text search.

Using Docker makes setup seamless — and with Laravel Scout, you can be up and running in just a few commands.

๐Ÿ“ To learn more about Laravel Scout visit the documentation Laravel Scout

 

Ready to power up your Laravel app with real-time search? Give Meilisearch a try!

Happy Coding

Related Blogs
๐Ÿง  Mastering The Singleton Pattern In Laravel For Payment Gateways (Stripe, SSLCommerz, Bkash)
Singleton Laravel Payment Gateway

Integrating payment gateways like Stripe, SSLCommerz, or Bkash is a common need in web development. But if not done right, it can lead to messy, repeated code and poor resource management. In this blog, weโ€™ll explore how to implement a clean, scalable, and reusable payment system using the Singleton Pattern, Strategy Pattern, and Dependency Injection in Laravel.

Profile Picture Joton Sutradhar โ€ข ๐Ÿ“– 4 min read โ€ข ๐Ÿ“… 24th June 2025
Clean Code, Scalable Systems: The Abstract Service Advantage In Laravel
PHP Laravel Abstraction Abstract Service Joton Sutradhar

Alright, Laravel developers, let's talk shop. We love Laravel for its elegance, convention over configuration, and how quickly it lets us build. But as our applications grow, even in a framework as opinionated as Laravel, we can fall into traps: repeating the same logic across different "service" classes, inconsistent data handling, or struggling to manage complex workflows.

Profile Picture Joton Sutradhar โ€ข ๐Ÿ“– 11 min read โ€ข ๐Ÿ“… 20th June 2025
๐Ÿš€ Laravel Horizon: A Step-by-Step Guide For Managing Queues Like A Pro
Queue Jobs Laravel Horizon

Queues are essential for building scalable and performant Laravel applications. Whether you're sending emails, processing files, or executing time-consuming tasks, queues offload work and keep your app fast. But how do you monitor and manage them effectively?

Profile Picture Joton Sutradhar โ€ข ๐Ÿ“– 3 min read โ€ข ๐Ÿ“… 2nd June 2025
Subscribe to my newsletter

Get recent projects & blog updates to your inbox.

I never share your email. Read our privacy policy.

© 2025 Joton Sutradhar. All rights reserved.