Skip to content

WorkerManager

Centralized state management for any persistent worker runtime (see WorkerRuntimeInterface), ensuring request-specific state is properly reset between requests while preserving performance-critical cached data.

class WorkerManager

Since1.0.0
SourceUtil/WorkerManager.php
MethodDescription
configure(array<string, mixed> $config): voidConfigure worker behavior
getRequestCount(): intGet current request count
getStatistics(): array<string, mixed>Get worker statistics
initialize(array<string, mixed> $options = []): voidInitialize the worker manager with configuration options
manageDatabaseConnections(string $strategy = 'keep'): voidHelper method for database connection management in worker mode
[`resetForNextRequest(stringarray<string, mixed>
[`resetObjects(array<intstring, mixed> $objects, bool $skipErrors = true): void`](#resetobjects)
shutdown(): voidShutdown the worker manager and perform cleanup

public static function configure(array<string, mixed> $config): void

Configure worker behavior

Configuration options

ParameterTypeDescription
$configarray``<``string``, ``mixed``>Configuration options

public static function getRequestCount(): int

Get current request count

Returns int — Number of requests processed

public static function getStatistics(): array<string, mixed>

Get worker statistics

Returns array``<``string``, ``mixed``> — Worker statistics

public static function initialize(array<string, mixed> $options = []): void

Initialize the worker manager with configuration options

Configuration options

ParameterTypeDescription
$optionsarray``<``string``, ``mixed``>Configuration options

public static function manageDatabaseConnections(string $strategy = 'keep'): void

Helper method for database connection management in worker mode

Connection management strategy: ‘keep’ (default), ‘close’, or ‘reset’

ParameterTypeDescription
$strategystringConnection management strategy: ‘keep’ (default), ‘close’, or ‘reset’

public static function resetForNextRequest(string|array<string, mixed>|null $contextProfile = null, array<string, mixed> $options = []): void

Reset all framework state for the next request in worker mode

Override default reset options

ParameterTypeDescription
$contextProfile`string“array<string, mixed>“
$optionsarray``<``string``, ``mixed``>Override default reset options

public static function resetObjects(array<int|string, mixed> $objects, bool $skipErrors = true): void

This method should be called to reset any long-lived objects that might hold request-specific state between FrankenPHP worker requests.

Whether to continue if reset fails for some objects

ParameterTypeDescription
$objects`array<int“string, mixed>`
$skipErrorsboolWhether to continue if reset fails for some objects

public static function shutdown(): void

Shutdown the worker manager and perform cleanup