class EngineManager

Manages search engine instances and driver creation.

EngineManager is auto-singletoned by the container, so its instance cache is shared across coroutines for the worker lifetime.

Properties

protected Engine> $engines

The resolved engine instances.

protected Closure> $customCreators

The registered custom driver creators.

Methods

__construct(Container $container)

Create a new engine manager instance.

engine(string|null $name = null)

Get an engine instance by name.

resolve(string $name)

Resolve the given engine.

callCustomCreator(string $name)

Call a custom driver creator.

createAlgoliaDriver()

Create an Algolia engine instance.

void
ensureAlgoliaClientIsInstalled()

Ensure the Algolia client is installed.

createMeilisearchDriver()

Create a Meilisearch engine instance.

void
ensureMeilisearchClientIsInstalled()

Ensure the Meilisearch client is installed.

createTypesenseDriver()

Create a Typesense engine instance.

void
ensureTypesenseClientIsInstalled()

Ensure the Typesense client is installed.

createCollectionDriver()

Create a collection engine instance.

createDatabaseDriver()

Create a database engine instance.

createNullDriver()

Create a null engine instance.

extend(string $driver, Closure $callback)

Register a custom driver creator.

forgetEngines()

Forget all of the resolved engine instances.

forgetEngine(string $name)

Forget a specific resolved engine instance.

string
getDefaultDriver()

Get the default Scout driver name.

mixed
getConfig(string $key, mixed $default = null)

Get a Scout configuration value.

Details

at line 49
__construct(Container $container)

Create a new engine manager instance.

Parameters

Container $container

at line 57
Engine engine(string|null $name = null)

Get an engine instance by name.

Parameters

string|null $name

Return Value

Engine

at line 69
protected Engine resolve(string $name)

Resolve the given engine.

Parameters

string $name

Return Value

Engine

Exceptions

InvalidArgumentException

at line 87
protected Engine callCustomCreator(string $name)

Call a custom driver creator.

Parameters

string $name

Return Value

Engine

at line 97
AlgoliaEngine createAlgoliaDriver()

Create an Algolia engine instance.

Return Value

AlgoliaEngine

Exceptions

RuntimeException

at line 113
protected void ensureAlgoliaClientIsInstalled()

Ensure the Algolia client is installed.

Return Value

void

Exceptions

RuntimeException

at line 127
MeilisearchEngine createMeilisearchDriver()

Create a Meilisearch engine instance.

Return Value

MeilisearchEngine

at line 142
protected void ensureMeilisearchClientIsInstalled()

Ensure the Meilisearch client is installed.

Return Value

void

Exceptions

RuntimeException

at line 158
TypesenseEngine createTypesenseDriver()

Create a Typesense engine instance.

Return Value

TypesenseEngine

Exceptions

RuntimeException

at line 173
protected void ensureTypesenseClientIsInstalled()

Ensure the Typesense client is installed.

Return Value

void

Exceptions

RuntimeException

at line 187
CollectionEngine createCollectionDriver()

Create a collection engine instance.

Return Value

CollectionEngine

at line 195
DatabaseEngine createDatabaseDriver()

Create a database engine instance.

Return Value

DatabaseEngine

at line 203
NullEngine createNullDriver()

Create a null engine instance.

Return Value

NullEngine

at line 214
EngineManager extend(string $driver, Closure $callback)

Register a custom driver creator.

Boot-only. The callback persists in the singleton's customCreators array for the worker lifetime and applies to every subsequent engine resolution.

Parameters

string $driver
Closure $callback

Return Value

EngineManager

at line 228
EngineManager forgetEngines()

Forget all of the resolved engine instances.

Boot or tests only. Clears the manager's engine cache; concurrent coroutines may already hold references that next resolution will not share.

Return Value

EngineManager

at line 242
EngineManager forgetEngine(string $name)

Forget a specific resolved engine instance.

Boot or tests only. Mutates the manager's engine cache; concurrent coroutines may already hold a reference to the engine and next resolution will rebuild.

Parameters

string $name

Return Value

EngineManager

at line 252
string getDefaultDriver()

Get the default Scout driver name.

Return Value

string

at line 262
protected mixed getConfig(string $key, mixed $default = null)

Get a Scout configuration value.

Parameters

string $key
mixed $default

Return Value

mixed