symfony-messenger

Installation
SKILL.md

Symfony Messenger (Symfony)

Use when

  • Moving slow or failure-prone work out of the request into a message and an #[AsMessageHandler] handler.
  • Choosing a transport (Doctrine, Redis, AMQP, sync://, in-memory://) and routing messages to it.
  • Running, sizing, and restarting workers with messenger:consume.
  • Making handlers safe under redelivery.

Default workflow

  1. Create the message as a plain readonly class that carries IDs, never entities.
  2. Write the handler with #[AsMessageHandler] and a typed __invoke(): refetch by ID, skip work already done.
  3. Route the message with #[AsMessage('async')] or the routing key, and declare the transport DSN in messenger.yaml.
  4. Set retry_strategy and failure_transport on the transport.
  5. Consume with messenger:consume async -vv, bounded by --limit, --memory-limit, or --time-limit.
  6. Check the wiring with debug:messenger and messenger:stats, and use in-memory:// in tests.
Installs
73
GitHub Stars
224
First Seen
Sep 17, 2026