- Can I use sulu/messenger in Laravel without Symfony?
- Yes, but with caveats. The package is Symfony-first, so you’ll need to bridge it via spatie/laravel-messenger or wrap Symfony components (e.g., symfony/messenger) in Laravel services. Middlewares like LockMiddleware require custom adapters for Eloquent or Laravel’s queue system.
- How do I integrate sulu/messenger with Laravel’s queue workers?
- Use spatie/laravel-messenger to bridge Symfony’s Messenger to Laravel’s queue:work. Map Symfony transports (e.g., AMQP) to Laravel drivers (Redis, database) via custom adapters. Middlewares like UnpackExceptionMiddleware will work if you handle Laravel’s ShouldQueue exceptions.
- What Laravel versions support sulu/messenger?
- Direct support isn’t guaranteed, but it works with Laravel 10+ if you use spatie/laravel-messenger (v2.0+) as a bridge. Test with symfony/messenger:^6.4 for compatibility. For older Laravel versions, abstract Symfony dependencies carefully.
- How does UnpackExceptionMiddleware improve error handling in Laravel?
- It exposes the *real* exception from HandlerFailedException, letting you map failures to HTTP status codes (e.g., 422 for validation errors) or log them cleanly. In Laravel, extend it to handle native exceptions like Throwables or ShouldQueue failures.
- Is LockMiddleware safe for production with Laravel’s Eloquent?
- Not natively—it’s Doctrine-focused. For Eloquent, use symfony/lock with a database/file backend (e.g., Redis) or add an optimistic_lock column. Test lock TTLs (5–30s) to avoid deadlocks under high concurrency.
- Will sulu/messenger slow down my Laravel queues?
- Middlewares add minimal overhead, but LockMiddleware or DoctrineFlushMiddleware (if adapted) can block jobs if misconfigured. Profile with real workloads (e.g., 1000 RPS) and use short lock durations or selective flushing for critical entities.
- Are there alternatives to sulu/messenger for Laravel?
- Yes: spatie/laravel-queue-scheduler for job scheduling, laravel-horizon for monitoring, or symfony/messenger directly with custom Laravel wrappers. For locking, consider symfony/lock or Laravel’s native mutexes (e.g., file-based).
- How do I test sulu/messenger middlewares in Laravel?
- Use Laravel’s Queue::fake() for unit tests and Dockerized environments for integration tests with locks/Doctrine. Mock Symfony’s TestBus or adapt it to Laravel’s queue system. Test error paths by throwing exceptions in message handlers.
- Can I use sulu/messenger without the SuluMessengerBundle?
- Yes, the package provides standalone stamps/middlewares. Skip the bundle if using Laravel and install only sulu/messenger via Composer. Configure middlewares manually in your Laravel service provider or spatie/laravel-messenger setup.
- What’s the effort to adapt DoctrineFlushMiddleware for Eloquent?
- Moderate. You’d need to create a custom middleware wrapping Eloquent’s flush() or save() methods, then integrate it into Laravel’s queue lifecycle (e.g., via queue:after hooks). Test thoroughly for transaction boundaries.