Getting Started
An Elasticsearch implementation of Laravel’s Eloquent ORM
This package extends Laravel’s Eloquent model and query builder with seamless integration of Elasticsearch functionalities. Designed to feel native to Laravel, this package enables you to work with Eloquent models while leveraging the powerful search and analytics capabilities of Elasticsearch.
Looking to use the OpenSearch version of this package? Github
Installation
Maintained versions
- Elasticsearch 8.x
Laravel 11 and 10 - main branch (tag 4.x
):
Laravel Version | Command | Maintained |
---|---|---|
Laravel 10 & 11 | composer require pdphilip/elasticsearch:~4 | ✅ |
Laravel 9 | composer require pdphilip/elasticsearch:~3.9 | ✅ |
Laravel 8 | composer require pdphilip/elasticsearch:~3.8 | ✅ |
Unmaintained versions
- Elasticsearch 8.x
Laravel Version | Command | Maintained |
---|---|---|
Laravel 7.x | composer require pdphilip/elasticsearch:~2.7 | ❌ |
Laravel 6.x (5.8) | composer require pdphilip/elasticsearch:~2.6 | ❌ |
- Elasticsearch 7.x
Laravel Version | Command | Maintained |
---|---|---|
Laravel 9.x | composer require pdphilip/elasticsearch:~1.9 | ❌ |
Laravel 8.x | composer require pdphilip/elasticsearch:~1.8 | ❌ |
Laravel 7.x | composer require pdphilip/elasticsearch:~1.7 | ❌ |
Laravel 6.x (5.8) | composer require pdphilip/elasticsearch:~1.6 | ❌ |
Configuration
- Set up your
.env
with the following Elasticsearch settings: For multiple nodes, pass in as comma-separated:Example cloud config .env: (Click to expand)
- In
config/database.php
, add the elasticsearch connection: - If packages are not autoloaded, add the service provider: For Laravel 10 and below: For Laravel 11:
Now, you’re all set to use Elasticsearch with Laravel as if it were native to the framework.