lacasera / elastic-bridge
An eloquent way to search
Fund package maintenance!
Requires
- php: ^8.2|^8.3
- elasticsearch/elasticsearch: ^8.14
- illuminate/contracts: ^10.0|^11.0|^12.0
- illuminate/database: ^10.0|^11.0|^12.0
- laravel/prompts: ^0.1.9|^0.2|^0.3|^0.4|^0.5
- opensearch-project/opensearch-php: ^2.6
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nesbot/carbon: ^2.63|^3.8.4
- nunomaduro/collision: ^8.1.1|^7.10.0
- nyholm/psr7: ^1.8
- orchestra/testbench: ^8.22.0|^9.0.0|^10.0.0
- php-http/mock-client: ^1.6
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.11
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^10.5
- rector/rector: ^1.2
Suggests
- aws/aws-sdk-php: Required only for OpenSearch AWS SigV4 authentication (elasticbridge.auth_method=sigv4).
This package is auto-updated.
Last update: 2026-08-10 12:26:22 UTC
README
An Eloquent Way To Search.
ElasticBridge allows you to write Fluent, Eloquent like queries against Elasticsearch and OpenSearch in your Laravel application.
With ElasticBridge, you can interact with your search indexes as easily as you would with traditional Eloquent models — full-text search, filters, aggregations, attribute casting, bulk indexing, and multi-index queries — bringing the power of Elasticsearch/OpenSearch into the Laravel ecosystem with no effort.
Requirements
- PHP 8.2 or 8.3
- Laravel 10.x, 11.x, or 12.x
- Elasticsearch 8.x or OpenSearch 2.x
Compatibility Matrix
| Laravel Version | PHP Version | Testbench Version | Carbon Version | PHPUnit Version |
|---|---|---|---|---|
| 10.x | 8.2, 8.3 | 8.* | ^2.63 | ^10.5 |
| 11.x | 8.2, 8.3 | 9.* | ^2.63 | ^10.5 |
| 12.x | 8.3 | 10.* | ^3.8.4 | ^11.5.3 |
Installation
Install the package via Composer:
composer require lacasera/elastic-bridge
Overview
php artisan make:bridge HotelRoom
<?php declare(strict_types=1); namespace App\Bridges; use Lacasera\ElasticBridge\ElasticBridge; class HotelRoom extends ElasticBridge { }
<?php declare(strict_types=1); namespace App\Http\Controllers; use App\Bridges\HotelRoom; use App\Requests\SearhRequest; class SearchController extends Controller { public function __invoke(SearhRequest $request) { $rooms = HotelRoom::asBoolean() ->matchAll() ->orderBy('price', 'DESC'), ->filterByTerm('code', 'usd') ->filterByRange('price', 20, 'gte') ->filterByRange('price', 500, 'lte') ->cursorPaginate(50) ->get(['price']); return response()->json([ 'data' => $rooms ]); } }
Documentation
AI-assisted development
ElasticBridge is built to be first-class for AI coding agents:
- Laravel Boost skill & guidelines. The package ships an
elastic-bridge-developmentskill and core guidelines. If your project uses Laravel Boost, runphp artisan boost:installand your agent automatically gets ElasticBridge-specific guidance. - LLM-friendly docs. The documentation is published in the
llms.txtformat at elasticbridge.dev/llms.txt (index) and elasticbridge.dev/llms-full.txt (full text) so LLMs can read the whole API in one fetch.
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
TODO [] Add logging for queries and response...