- How do I install and set up **cptburke/symfony-messenger-application** in a Laravel project?
- Run `composer require cptburke/symfony-messenger-application` and configure it in `bootstrap/app.php` or a service provider. The package provides an application wrapper to initialize Symfony Messenger components like transports, buses, and handlers. You’ll need to define message classes and routes in your config, similar to Symfony’s setup but adapted for Laravel’s structure.
- Does this package support Laravel’s native queue drivers (Redis, database, SQS) out of the box?
- No, this package does not natively support Laravel’s queue drivers. It relies on Symfony Messenger’s transports, so you’d need to implement custom transports (e.g., Redis or SQS) to bridge the gap. The package is designed for projects already using or willing to adopt Symfony Messenger’s transport ecosystem.
- Can I use this with Laravel 10 and PHP 8.2+?
- The package’s last release was in 2021, so it may not fully support PHP 8.2+ features like enums or attributes, nor Laravel 10 optimizations. You’d need to fork or patch it for compatibility, or consider alternatives like `spatie/laravel-messenger`, which is actively maintained for modern Laravel versions.
- How does this compare to Laravel’s built-in `queue:work` command?
- This package is for projects needing advanced features like multi-transport routing, custom middleware, or message buses—beyond Laravel’s queues. It wraps Symfony Messenger, offering finer control over message handling but adds complexity. For simple background jobs, Laravel’s `queue:work` is lighter and more integrated.
- Will this work with Laravel Horizon for monitoring workers?
- No, this package doesn’t natively integrate with Laravel Horizon. Horizon relies on Laravel’s queue system, while this package uses Symfony Messenger’s abstraction. You’d need to build custom monitoring or use Symfony Messenger’s tools (e.g., `messenger:consume`).
- Can I dispatch messages from Laravel controllers or jobs using this package?
- Yes, the package provides a Symfony Messenger bus that you can inject into Laravel services (via the service container). Dispatch messages like `$bus->dispatch(new YourMessage())` from controllers, jobs, or commands. Ensure your message classes follow Symfony Messenger’s standards (e.g., `__invoke()` or `handle()` methods).
- What’s the performance overhead of using this wrapper vs. Laravel’s queues?
- The wrapper adds minimal overhead for bootstrapping but introduces Symfony Messenger’s abstraction layer, which may slightly increase memory usage compared to Laravel’s queues. Benchmark your specific use case, as performance depends on transports (e.g., Redis vs. AMQP) and message complexity.
- How do I run workers/consumers with this package?
- The package provides an application-style setup for workers. Use the wrapper’s `run()` method in a custom Artisan command or CLI script to start consumers. For example, create a command like `php artisan messenger:consume` that initializes the application and runs `messenger:consume`.
- Are there alternatives to this package for Laravel + Symfony Messenger?
- Yes, consider `spatie/laravel-messenger`, which is actively maintained and offers tighter Laravel integration (e.g., queue drivers, Horizon support). If you need minimalism and don’t mind Symfony dependencies, this package is a lightweight option, but Spatie’s version is more Laravel-native.
- How do I handle failed messages or retries with this package?
- Symfony Messenger supports retries and failed message handling via transports (e.g., Doctrine transport) and middleware. Configure retry logic in your transport or bus setup. However, this package lacks Laravel’s job middleware (e.g., `retryAfter`), so you’d need to implement custom solutions or use Symfony’s retry mechanisms.