- Can I use symfony/messenger in a Laravel application?
- Yes. It is a standalone Symfony component installable with Composer, so Laravel can use its message buses, transports, middleware, and handlers. There is no Laravel-specific version matrix; compatibility is driven by your PHP version and Symfony component constraints. You will typically add glue code for Laravel's container and config and run Messenger workers alongside or instead of Laravel queue workers.
- How do I install and configure symfony/messenger in Laravel?
- Run composer require symfony/messenger, then add transport packages such as symfony/redis-messenger, symfony/amqp-messenger, or symfony/doctrine-messenger. Configure transports, buses, routing, and middleware in your own Laravel config or service-provider layer because Laravel does not ship Messenger config out of the box. Keep serializer and transport DSN settings explicit, and verify the component version matches your PHP and Laravel dependency constraints.
- Which transports does Symfony Messenger support?
- It supports Redis, AMQP/RabbitMQ via symfony/amqp-messenger, Doctrine/DB, and in-memory or sync transports, among others. Transport choice affects retry behavior, failure transports, and header handling; AMQP is specifically affected by restrictions on X-Message-Stamp-* headers. For Laravel teams, Redis and Doctrine are common drop-in options, while AMQP requires the extra package and broker setup.
- How does symfony/messenger compare to Laravel queues?
- Laravel queues are tightly integrated with Laravel and Horizon, while Messenger provides a bus and middleware model with explicit stamps, routing, and multiple transport abstractions. You can use Messenger as a drop-in replacement, a hybrid approach, or side-by-side with Laravel queues. Messenger is stronger for complex event-driven workflows and custom middleware; Laravel queues are simpler for basic background jobs.
- Is symfony/messenger production-ready in Laravel?
- It is stable and widely used, but production adoption depends on pinning a version that includes the latest security fixes. The v5.4.54 security release closed envelope, deserialization, and AMQP header trust-boundary issues, so verify the equivalent fix exists on your chosen branch. Also audit custom stamps, failure transports, and worker retry configuration before rollout.
- What changed with custom stamps in recent Messenger security releases?
- Messages carrying non-sendable stamps are now rejected at decode time, and stamps on unserialized envelopes are validated. If you authored custom stamps, they must satisfy Messenger's sendability contract or consumption will fail. This is a potential breaking change and the most likely source of post-upgrade production issues.
- How do I test symfony/messenger integration in Laravel?
- Use the in-memory or sync transport in tests to avoid a real broker, and assert dispatched messages through your bus or handler layer. For Laravel, wrap Messenger bus calls in your own test helpers or bind a test double in the container. Test failure paths, retry middleware, and stamp sendability, not just happy-path dispatch.
- What are the security concerns with symfony/messenger queues?
- The main risk is a writable queue or broker allowing crafted envelopes, stamps, or X-Message-Stamp-* headers to enter message construction. The recent fixes validate stamps, restrict header-based stamps, and reduce trace-argument leakage in FlattenException normalization. Treat shared or multi-tenant queues as higher risk and apply the security patch even if only your own workers publish.
- Which Symfony Messenger version should I pin for Laravel?
- Pin a version on a maintained branch that contains the security fixes relevant to your transports, and verify the advisory-to-patch mapping rather than assuming a fix on another line covers your pin. The v5.4.54 release is a security backport, so confirm whether your 8.1 or other line has the equivalent changes. Also check PHP and dependency constraints before upgrading.
- What are alternatives to symfony/messenger for Laravel?
- Laravel's native queue system with Horizon is the closest alternative for simple background jobs. Other options include Enqueue, Bunny for RabbitMQ, or custom bus implementations, but they will not match Messenger's Symfony serializer and middleware ecosystem. Choose Messenger when you need explicit buses, stamps, routing, and transport abstraction across Symfony and Laravel codebases.