cptburke/symfony-messenger-application
Laravel package that integrates Symfony Messenger into a Laravel application, providing an application-level wrapper to configure transports and routing, dispatch messages, and run workers/consumers using familiar Laravel-friendly commands and configuration.
queue:work) are insufficient.symfony/messenger), which are not natively Laravel-compatible. Laravel’s queue system (e.g., queue:work) uses a different abstraction layer (e.g., Illuminate\Queue).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Symfony Dependency | High | Abstract Symfony Messenger behind a facade or adapter layer. |
| Lack of Maintenance | Medium | Fork and modernize (PHP 8.2+, Laravel 10) or replace with spatie/laravel-messenger. |
| Queue Driver Mismatch | High | Implement custom transports for Laravel’s drivers (e.g., Redis, SQS). |
| Bootstrapping Complexity | Medium | Leverage Laravel’s bootstrap/app.php to initialize the wrapper. |
Why Symfony Messenger?
Alternatives Evaluation
spatie/laravel-messenger (Symfony Messenger for Laravel) or Laravel’s native queues suffice?Long-Term Viability
Performance Impact
queue:work).| Component | Compatibility Notes |
|---|---|
| Laravel Service Container | Low (Symfony Messenger uses its own DI). Workaround: Use Laravel’s container as a parent. |
| Queue Drivers | Medium (Redis/SQS may work; others need custom transports). |
| Artisan Commands | High (can wrap Symfony Messenger workers in Laravel commands). |
| Laravel Events | Low (no native bridge; would require custom event-to-message converters). |
| Horizon Monitoring | None (would need custom integration). |
composer require symfony/messenger symfony/amqp-messenger symfony/redis-messenger
config/queue.php to use Redis (recommended for compatibility).SymfonyMessengerApplication:
use CptBurke\SymfonyMessengerApplication\Application;
use Symfony\Component\Messenger\MessageBus;
public function boot(): void
{
$application = new Application();
$bus = $application->getBus();
$this->app->singleton(MessageBus::class, fn() => $bus);
}
queue:work with a custom Artisan command:
use CptBurke\SymfonyMessengerApplication\Worker;
Artisan::command('messenger:work', function () {
$worker = new Worker($this->app->make(MessageBus::class));
$worker->run();
});
@AsMessageHandler or configure manually).monolog or ELK stack.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Worker Crash | Unprocessed messages | Use Symfony Messenger’s retry logic + Laravel’s failed job table. |
| Transport Failure (Redis) | Message loss | Enable persistent connections and monitor transport health. |
| Message Handler Exceptions | Poison pills | Implement dead-letter queues (Symfony Messenger supports this). |
| Laravel Cache/Config Issues | Worker startup failures | Isolate Symfony Messenger config from Laravel’s cache. |
| PHP Version Incompatibility | Runtime errors | Use PHP 8.1 (last LTS before 8.2) or fork the package. |
How can I help you explore Laravel packages today?