DoctrineDriver
in package
implements
MessageDriverInterface
FinalYes
Minimal PDO-based driver storing messages in a single table.
Table schema suggestion:
CREATE TABLE queue_messages ( id VARCHAR(64) PRIMARY KEY, class VARCHAR(255) NOT NULL, body LONGTEXT NOT NULL, attempts INT NOT NULL DEFAULT 0, available_at BIGINT NOT NULL, created_at BIGINT NOT NULL, meta JSON NULL );
Index on available_at for faster polling.
Table of Contents
Interfaces
- MessageDriverInterface
- Minimal driver interface for queue backends.
Properties
Methods
- __construct() : mixed
- getMessage() : array<string|int, mixed>|null
- Return message envelope by id or null if not found.
- isOnline() : bool
- Health check
- listKeys() : iterable<string|int, string>
- Return iterable of message IDs (strings).
- remove() : bool
- saveMessage() : string
- Save an envelope into the queue.
Properties
$pdo
private
PDO
$pdo
$table
private
string
$table
Methods
__construct()
public
__construct(PDO $pdo[, string $table = 'queue_messages' ]) : mixed
Parameters
- $pdo : PDO
- $table : string = 'queue_messages'
getMessage()
Return message envelope by id or null if not found.
public
getMessage(string $key) : array<string|int, mixed>|null
Envelope is an associative array with keys:
- id: string
- class: string (task class)
- body: mixed (serialized payload)
- attempts: int
- available_at: int (unix ts ms)
- created_at: int (unix ts ms)
- meta: array
Parameters
- $key : string
Return values
array<string|int, mixed>|nullisOnline()
Health check
public
isOnline() : bool
Return values
boollistKeys()
Return iterable of message IDs (strings).
public
listKeys() : iterable<string|int, string>
Implementations may return in-queue order.
Return values
iterable<string|int, string>remove()
public
remove(string $key) : bool
Parameters
- $key : string
Return values
boolsaveMessage()
Save an envelope into the queue.
public
saveMessage(array<string|int, mixed> $envelope[, string $position = 'append' ]) : string
Parameters
- $envelope : array<string|int, mixed>
- $position : string = 'append'
-
'append'|'prepend'
Return values
string —saved id