The MessengerBundle provides integration of the invis1ble/messenger library into the Symfony framework.
Version 6.2 adds Symfony 8 support and requires invis1ble/messenger 5.1 or later
within the 5.x series. Public bus interfaces and service IDs are unchanged.
| Symfony | PHP requirement |
|---|---|
| 6.4 / 7.x | PHP 8.2+ |
| 8.0 | PHP 8.4+ |
| 8.1 | PHP 8.4.1+ |
Stable dependencies are used by default. CI checks Symfony 6.4, 7.4, 8.0, and 8.1,
including a real kernel, lint:container, and message dispatch in prod and test.
To upgrade an existing Symfony 8.1 application, run Composer on PHP 8.4.1 or later:
composer require 'invis1ble/messenger-bundle:^6.2' --with-all-dependenciesWhen upgrading Symfony itself, also update the application's Symfony constraints
and its extra.symfony.require setting if Symfony Flex uses it to restrict versions.
No platform requirement bypass is needed.
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Open a command console, enter your project directory and execute:
$ composer require invis1ble/messenger-bundleOpen a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require invis1ble/messenger-bundleThen, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php file of your project:
// config/bundles.php
return [
// ...
Invis1ble\MessengerBundle\Invis1bleMessengerBundle::class => ['all' => true],
];Enable Symfony's FrameworkBundle and configure MESSENGER_TRANSPORT_DSN for the
async transport. The bundle provides these services and autowired interfaces:
| Bus interface | Symfony service ID | Handler interface |
|---|---|---|
Invis1ble\Messenger\Command\CommandBusInterface |
messenger.bus.command |
Invis1ble\Messenger\Command\CommandHandlerInterface |
Invis1ble\Messenger\Query\QueryBusInterface |
messenger.bus.query |
Invis1ble\Messenger\Query\QueryHandlerInterface |
Invis1ble\Messenger\Event\EventBusInterface |
messenger.bus.event.async |
Invis1ble\Messenger\Event\EventHandlerInterface |
Register handlers as services with autoconfigure: true and implement the matching
handler interface. The bundle assigns each handler to its corresponding bus; an
additional messenger.message_handler tag or #[AsMessageHandler] is unnecessary.
Command and query buses handle messages synchronously. The event bus is the default
Symfony bus and permits events without handlers.
Route events to the async transport in your application, for example:
# config/packages/messenger.yaml
framework:
messenger:
routing:
'Invis1ble\Messenger\Event\EventInterface': asyncConsume queued events with php bin/console messenger:consume async. In the test
environment the bundle uses sync:// for this transport and decorates all three
bus interfaces with traceable buses, so routed events are handled immediately.
Application configuration can override the bundle's defaults, including transports
and retry policies.
- If not already done, install Docker Compose (v2.10+)
- Run
docker compose build --no-cacheto build fresh images - Run
docker compose up -d --waitto start the Docker containers - Run
docker compose exec php composer installto install dependencies - Run
docker compose down --remove-orphansto stop the Docker containers.
The development image uses PHP 8.5. To use PHP 8.4, set PHP_VERSION=8.4 for both
the build and subsequent Compose commands. For a clean dependency resolution, use
a fresh checkout without vendor/ or composer.lock.
Run all package checks:
docker compose exec -T php composer checkRun PHP_CodeSniffer checks:
docker compose exec -it php bin/php_codesnifferRun PHP-CS-Fixer checks:
docker compose exec -it php bin/php-cs-fixerTo run Unit tests during development
docker compose exec php vendor/bin/phpunitTo run with coverage
XDEBUG_MODE=coverage docker compose up -d --wait
docker compose exec php vendor/bin/phpunit --coverage-clover var/log/coverage-clover.xml