final class MessageSerializer (View source)

internal  Applications should register MessageCodecInterface implementations instead of invoking this persistence boundary directly.
 

Persists registered messages in bounded, versioned JSON envelopes authenticated before hydration.

This serializer is a database-transport boundary. It never accepts legacy PHP serialization and derives a queue-specific HMAC key from the application's stable secret.

Constants

private ENVELOPE_VERSION

private KEY_INFO

Methods

__construct(MessageCodecRegistry $codecs, string $applicationSecret, int $maxPayloadBytes = 1048576, int $maxJsonDepth = 32)

Creates a bounded serializer over an explicit codec allow-list and application secret.

string
encode(object $message)

Encodes a registered message as an authenticated envelope suitable for database persistence.

string
object
decode(string $payload)

Verifies a persisted envelope before resolving its alias or invoking a hydration codec.

object

Details

__construct

__construct(MessageCodecRegistry $codecs, string $applicationSecret, int $maxPayloadBytes = 1048576, int $maxJsonDepth = 32)

Creates a bounded serializer over an explicit codec allow-list and application secret.

Parameters

MessageCodecRegistry $codecs
string $applicationSecret
int $maxPayloadBytes
int $maxJsonDepth

Exceptions

LogicException

encode

string encode(object $message)

Encodes a registered message as an authenticated envelope suitable for database persistence.

Parameters

object $message

Return Value

string

Exceptions

LogicException

decode

object decode(string $payload)

Verifies a persisted envelope before resolving its alias or invoking a hydration codec.

Parameters

string $payload

Return Value

object

Exceptions

InvalidQueuePayloadException