Deploying a Laravel application with Sail, along with either Meilisearch or Typesense, can be done using Docker. Since you are already using Sail, which is a Docker-based solution, it should be relatively straightforward to add either Meilisearch or Typesense to your setup. Below, I'll provide a step-by-step guide for both options.
Deploying with Meilisearch
-
Add Meilisearch to your
docker-compose.ymlfile:version: '3' services: # Other services like app, db, etc. meilisearch: image: getmeili/meilisearch:latest ports: - "7700:7700" volumes: - meilisearch_data:/meili_data environment: MEILI_NO_ANALYTICS: "true" volumes: meilisearch_data: -
Update your Laravel configuration:
In your
.envfile, add the following:MEILISEARCH_HOST=http://meilisearch:7700 -
Install the Laravel Scout and Meilisearch driver:
composer require laravel/scout meilisearch/meilisearch-php -
Configure Scout to use Meilisearch:
In your
config/scout.phpfile, set the driver tomeilisearch:'driver' => env('SCOUT_DRIVER', 'meilisearch'), -
Run your Docker containers:
./vendor/bin/sail up -d
Deploying with Typesense
-
Add Typesense to your
docker-compose.ymlfile:version: '3' services: # Other services like app, db, etc. typesense: image: typesense/typesense:latest ports: - "8108:8108" volumes: - typesense_data:/data environment: TYPESENSE_API_KEY: "your-typesense-api-key" TYPESENSE_DATA_DIR: "/data" TYPESENSE_ENABLE_CORS: "true" volumes: typesense_data: -
Update your Laravel configuration:
In your
.envfile, add the following:TYPESENSE_HOST=http://typesense:8108 TYPESENSE_API_KEY=your-typesense-api-key -
Install the Laravel Scout and Typesense driver:
composer require laravel/scout typesense/typesense-laravel-scout -
Configure Scout to use Typesense:
In your
config/scout.phpfile, set the driver totypesense:'driver' => env('SCOUT_DRIVER', 'typesense'), -
Run your Docker containers:
./vendor/bin/sail up -d
Choosing Between Meilisearch and Typesense
Both Meilisearch and Typesense are excellent search engines, and the choice between them can depend on your specific needs:
- Meilisearch is known for its ease of use and speed. It is a good choice if you want a simple setup and fast search capabilities.
- Typesense offers more advanced features like multi-tenant support and fine-grained control over search behavior. It might be a better choice if you need more customization and control.
Given that you are already using Docker with Sail, deploying either Meilisearch or Typesense should be relatively straightforward. Choose the one that best fits your project's requirements and follow the steps above to integrate it into your Laravel application.