schranz-search / laravel-package
An integration of CMS-IG SEAL search abstraction into Laravel Framework.
Fund package maintenance!
alexander-schranz
paypal.me/L91
Requires
- php: ^8.1
- illuminate/console: ^8.0 || ^9.0 || ^10.0 || ^11.0
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0
- illuminate/view: ^8.0 || ^9.0 || ^10.0 || ^11.0
- schranz-search/seal: ^0.5
Requires (Dev)
- php-cs-fixer/shim: ^3.51
- phpstan/extension-installer: ^1.2
- phpstan/phpstan: ^1.10
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^10.3
- rector/rector: ^1.0
- schranz-search/seal-algolia-adapter: ^0.5
- schranz-search/seal-elasticsearch-adapter: ^0.5
- schranz-search/seal-loupe-adapter: ^0.5
- schranz-search/seal-meilisearch-adapter: ^0.5
- schranz-search/seal-memory-adapter: ^0.5
- schranz-search/seal-multi-adapter: ^0.5
- schranz-search/seal-opensearch-adapter: ^0.5
- schranz-search/seal-read-write-adapter: ^0.5
- schranz-search/seal-redisearch-adapter: ^0.5
- schranz-search/seal-solr-adapter: ^0.5
- schranz-search/seal-typesense-adapter: ^0.5
Conflicts
- schranz-search/seal-algolia-adapter: <0.5 || >=0.6
- schranz-search/seal-elasticsearch-adapter: <0.5 || >=0.6
- schranz-search/seal-loupe-adapter: <0.5 || >=0.6
- schranz-search/seal-meilisearch-adapter: <0.5 || >=0.6
- schranz-search/seal-memory-adapter: <0.5 || >=0.6
- schranz-search/seal-multi-adapter: <0.5 || >=0.6
- schranz-search/seal-opensearch-adapter: <0.5 || >=0.6
- schranz-search/seal-read-write-adapter: <0.5 || >=0.6
- schranz-search/seal-redisearch-adapter: <0.5 || >=0.6
- schranz-search/seal-solr-adapter: <0.5 || >=0.6
- schranz-search/seal-typesense-adapter: <0.5 || >=0.6
README
Logo created by Meine WilmaSEAL
Laravel Integration
Integration of the CMS-IG — Search Engine Abstraction Layer (SEAL) into Laravel.
Note: This is part of the
cmsig/search
project create issues in the main repository.
Note: This project is heavily under development and any feedback is greatly appreciated.
Installation
Use composer for install the package:
composer require cmsig/seal-laravel-package
Also install one of the listed adapters.
List of adapters
The following adapters are available:
- MemoryAdapter:
cmsig/seal-memory-adapter
- ElasticsearchAdapter:
cmsig/seal-elasticsearch-adapter
- OpensearchAdapter:
cmsig/seal-opensearch-adapter
- MeilisearchAdapter:
cmsig/seal-meilisearch-adapter
- AlgoliaAdapter:
cmsig/seal-algolia-adapter
- SolrAdapter:
cmsig/seal-solr-adapter
- RediSearchAdapter:
cmsig/seal-redisearch-adapter
- TypesenseAdapter:
cmsig/seal-typesense-adapter
- ... more coming soon
Additional Wrapper adapters:
- ReadWriteAdapter:
cmsig/seal-read-write-adapter
- MultiAdapter:
cmsig/seal-multi-adapter
Creating your own adapter? Add the seal-php-adapter
Topic to your Github Repository.
Usage
The following code shows how to configure the package:
<?php // config/cmsig_seal.php return [ /* |-------------------------------------------------------------------------- | Schema configs |-------------------------------------------------------------------------- | | Define different directories for the schema loader. */ 'schemas' => [ 'app' => [ 'dir' => resource_path('schemas'), ], ], /* |-------------------------------------------------------------------------- | engines |-------------------------------------------------------------------------- | | Directory where the latte templates can be found. */ 'engines' => [ 'default' => [ 'adapter' => env( 'ENGINE_URL', 'meilisearch://127.0.0.1:7700', ), ], ], ];
A more complex configuration can be here found:
<?php // config/cmsig_seal.php return [ /* |-------------------------------------------------------------------------- | Schema configs |-------------------------------------------------------------------------- | | Define different directories for the schema loader. */ 'schemas' => [ 'app' => [ 'dir' => resource_path('schemas') . '/app', 'engine' => 'meilisearch', ], 'other' => [ 'dir' => resource_path('schemas') . '/other', 'engine' => 'algolia', ], ], /* |-------------------------------------------------------------------------- | engines |-------------------------------------------------------------------------- | | Directory where the latte templates can be found. */ 'engines' => [ 'algolia' => [ 'adapter' => 'algolia://' . env('ALGOLIA_APPLICATION_ID') . ':' . env('ALGOLIA_ADMIN_API_KEY'), ], 'elasticsearch' => [ 'adapter' => 'elasticsearch://127.0.0.1:9200', ], 'meilisearch' => [ 'adapter' => 'meilisearch://127.0.0.1:7700', ], 'memory' => [ 'adapter' => 'memory://', ], 'opensearch' => [ 'adapter' => 'opensearch://127.0.0.1:9200', ], 'redisearch' => [ 'adapter' => 'redis://supersecure@127.0.0.1:6379', ], 'solr' => [ 'adapter' => 'solr://127.0.0.1:8983', ], 'typesense' => [ 'adapter' => 'typesense://S3CR3T@127.0.0.1:8108', ], // ... 'multi' => [ 'adapter' => 'multi://elasticsearch?adapters[]=opensearch', ], 'read-write' => [ 'adapter' => 'read-write://elasticsearch?write=multi', ], ], /* |-------------------------------------------------------------------------- | Schema prefix |-------------------------------------------------------------------------- | | Define the prefix used for the index names to avoid conflicts. */ 'index_name_prefix' => '', ];
The default engine is available as Engine
:
class Some { public function __construct( private readonly \CmsIg\Seal\EngineInterface $engine, ) { } }
Multiple engines can be accessed via the EngineRegistry
:
class Some { private Engine $engine; public function __construct( private readonly \CmsIg\Seal\EngineRegistry $engineRegistry, ) { $this->engine = $this->engineRegistry->get('algolia'); } }
Instead of constructor injection the Laravel
integration provides also two Facades
for the above services:
CmsIg\Seal\Integration\Laravel\Facade\Engine
CmsIg\Seal\Integration\Laravel\Facade\EngineRegistry
How to create a Schema
file and use your Engine
can be found SEAL Documentation.
Commands
The package provides the following commands:
Create configured indexes
php artisan cmsig:seal:index-create --help
Drop configured indexes
php artisan cmsig:seal:index-drop --help