Skip to content

limenet/laravel-elastica-bridge

Repository files navigation

Laravel-Elastica Bridge

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status GitHub PHPStan Action Status codecov Total Downloads License Packagist PHP Version Support

A simple bridge between Laravel and Elasticsearch using Elastica, based on https://github.com/valantic/pimcore-elastica-bridge.

Requirements

Installation

You can install the package via composer:

composer require limenet/laravel-elastica-bridge

You can publish and run the migrations with:

php artisan vendor:publish --provider="Limenet\LaravelElasticaBridge\LaravelElasticaBridgeServiceProvider" --tag="elastica-bridge-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --provider="Limenet\LaravelElasticaBridge\LaravelElasticaBridgeServiceProvider" --tag="elastica-bridge-config"

This is the contents of the published config file:

return [
    'elasticsearch' => [
        'host' => env('ELASTICSEARCH_HOST', 'localhost'),
        'port' => env('ELASTICSEARCH_PORT', '9200'),
    ],
    'indices' => [],
    'events' => [
        'listen' => true,
    ],
];

Usage

  1. Add Limenet\LaravelElasticaBridge\Model\ElasticsearchableInterface and Limenet\LaravelElasticaBridge\Model\ElasticsearchableTrait to a model
  2. Create a class extending Limenet\LaravelElasticaBridge\Index\AbstractIndex
  3. Add the index to your config (elastica-bridge.indices)
  4. Run php artisan elastica-bridge:index
  5. Check using php artisan elastica-bridge:status

Testing

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.