cmsig/seal-memory-adapter
In-memory adapter for the SEAL search engine. Stores indexed documents in an array, making it ideal for tests and as a reference implementation. Use directly via Engine or via DSN: memory://
cmsig/seal-memory-adapter integrates seamlessly with Laravel’s modular architecture by leveraging the SEAL search abstraction layer, enabling a decoupled search implementation. This is particularly valuable for Laravel applications requiring search functionality (e.g., e-commerce, CMS, or analytics) where abstraction and flexibility are critical.null driver or supplementing existing search engines during development.memory://) simplifies integration via Laravel’s .env files, reducing boilerplate. Example:
SEAL_ADAPTER=memory://
cmsig/seal (core abstraction), which may introduce external dependencies (e.g., Elasticsearch clients if used downstream). Use composer why-not to audit conflicts.$schema = new \CmsIg\Seal\Schema\Builder();
$schema->addField('id', new \CmsIg\Seal\Field\StringField());
$schema->addField('name', new \CmsIg\Seal\Field\TextField());
cmsig/seal (parent project). Monitor the SEAL GitHub Discussions for updates.apcu) isn’t guaranteed. Concurrent writes in Laravel queues or Horizon could corrupt data. Mitigate with mutex locks or serialized access.TextField) and Laravel’s model attributes?OutOfMemory)?cmsig/seal project actively maintained? Are there alternatives (e.g., Laravel Scout’s Database driver, Meilisearch PHP SDK) with better Laravel integration?null driver or use as a local test double for search engines (e.g., Algolia, Meilisearch). Example:
// config/scout.php
'driver' => env('SCOUT_DRIVER', 'memory'),
AppServiceProvider:
public function boot() {
$this->app->bind(\CmsIg\Seal\Engine::class, function ($app) {
$schema = new \CmsIg\Seal\Schema\Builder();
// Define schema fields...
return new \CmsIg\Seal\Engine(
new \CmsIg\Seal\Adapter\Memory\MemoryAdapter(),
$schema
);
});
}
php artisan seal:memory:flush
refreshDatabase() or DatabaseTransactions for search-related tests. Example:
public function test_search_functionality() {
$engine = new \CmsIg\Seal\Engine(new \CmsIg\Seal\Adapter\Memory\MemoryAdapter(), $schema);
$engine->index(['id' => 1, 'name' => 'Test']);
$results = $engine->search('Test');
$this->assertCount(1, $results);
}
Phase 1: Proof of Concept (1–2 Days)
composer require cmsig/seal cmsig/seal-memory-adapter
Product):
$schema = new \CmsIg\Seal\Schema\Builder();
$schema->addField('id', new \CmsIg\Seal\Field\StringField());
$schema->addField('name', new \CmsIg\Seal\Field\TextField());
$engine = new \CmsIg\Seal\Engine(new \MemoryAdapter(), $schema);
$engine->index(['id' => 1, 'name' => 'Laptop']);
$results = $engine->search('Laptop');
Phase 2: Laravel Integration (2–3 Days)
config/seal.php:
'adapter' => env('SEAL_ADAPTER', 'memory'),
'memory' => [
'enabled' => true,
],
// app/Services/SearchService.php
class SearchService {
public function __construct(private \CmsIg\Seal\Engine $engine) {}
public function indexProduct(Product $product) {
$this->engine->index([
'id' => $product->id,
'name' => $product->name,
]);
}
}
Route::get('/search', function () {
$results = app(SearchService::class)->search('query');
return response()->json($results);
});
Phase 3: Dual-Write System (3–5 Days)
// app/Listeners/SyncToAlgolia.php
public function handle(SearchIndexed $event) {
Algolia::index($event->document)->save();
}
How can I help you explore Laravel packages today?