Skip to content

Additional tools for Laravel Scout 9+ integration with MeiliSearch

License

Notifications You must be signed in to change notification settings

AhmedAmiin0/laravel-meilitools

 
 

Repository files navigation

Laravel MeiliTools

PHP Packagist Downloads License GitHub Workflow Status

The purpose of this package is to ease the configuration of indexes for MeiliSearch, so it's possible to use advanced filtering and sorting through Laravel Scout, without having to meddle with their API manually.

Table of Contents

Installation

Install this package via Composer:

$ composer require dwarfdk/laravel-meilitools

Configuration

Publish config using Artisan command:

$ php artisan vendor:publish --provider="Dwarf\MeiliTools\MeiliToolsServiceProvider"

Change configuration through config/meilitools.php.

Usage

This package provides commands and helpers to ease the use of configuring MeiliSearch indexes.

Model Settings

Setup index settings for a model by implementing the method provided by the contract.

use Dwarf\MeiliTools\Contracts\Indexes\MeiliSettings;
use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;

class Article extends Model implements MeiliSettings
{
    use Searchable;
    
    /**
     * {@inheritdoc}
     */
    public function meiliSettings(): array
    {
        return ['filterableAttributes' => ['status']];
    }
}

A full list of available index settings can be found here.

Commands

The following commands are available:

meili:index:details - Get details for a MeiliSearch index

Arguments:

  • index : Index name

meili:index:reset - Reset settings for a MeiliSearch index

Arguments:

  • index : Index name

Options:

  • --pretend : Only shows what changes would have been done to the index

meili:model:details - Get details for a MeiliSearch model index

Arguments:

  • model : Model class

meili:model:reset - Reset settings for a MeiliSearch model index

Arguments:

  • model : Model class

Options:

  • --pretend : Only shows what changes would have been done to the index

meili:model:synchronize - Synchronize settings for a MeiliSearch model index

Arguments:

  • model : Model class

Options:

  • --pretend : Only shows what changes would have been done to the index

meili:models:synchronize - Synchronize all models implementing MeiliSearch index settings

Options:

  • --pretend : Only shows what changes would have been done to the indexes
  • --force : Force the operation to run when in production

Testing

Running tests can be done either through composer, or directly calling the PHPUnit binary.

$ composer test

To run tests with code coverage, please make sure that phpdbg exists and is executable.

$ composer test:coverage
$ open tests/_reports/index.html

Career

Dwarf A/S is a digital agency based in Copenhagen (Denmark) and established January 1st 2000.

We're always looking for new talent, so have a look at our website for job openings.

License

The MIT License (MIT). Please see License File for more information.

About

Additional tools for Laravel Scout 9+ integration with MeiliSearch

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%