symfony/symfony · error · LogicException
Messenger support cannot be enabled as the Messenger compone
Error message
Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".
What it means
Thrown by registerMessengerConfiguration() when Messenger is configured but the MessageBusInterface (from symfony/messenger) is not autoloadable. The extension guards every component integration with an interface/class existence check so that a missing package yields a clear, actionable message instead of a confusing class-not-found during service wiring. It is a compile-time LogicException.
Source
Thrown at src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php:2389
}
private function registerSchedulerConfiguration(ContainerBuilder $container, PhpFileLoader $loader): void
{
if (!class_exists(SchedulerTransportFactory::class)) {
throw new LogicException('Scheduler support cannot be enabled as the Scheduler component is not installed. Try running "composer require symfony/scheduler".');
}
$loader->load('scheduler.php');
if (!$this->hasConsole()) {
$container->removeDefinition('console.command.scheduler_debug');
}
}
private function registerMessengerConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader, bool $validationEnabled, bool $lockEnabled): void
{
if (!interface_exists(MessageBusInterface::class)) {
throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');
}
if (!$this->hasConsole()) {
$container->removeDefinition('console.command.messenger_stats');
}
$loader->load('messenger.php');
if (!interface_exists(DenormalizerInterface::class)) {
$container->removeDefinition('serializer.normalizer.flatten_exception');
}
if (ContainerBuilder::willBeAvailable('symfony/amqp-messenger', MessengerBridge\Amqp\Transport\AmqpTransportFactory::class, ['symfony/framework-bundle', 'symfony/messenger'])) {
$container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory');
}
if (ContainerBuilder::willBeAvailable('symfony/redis-messenger', MessengerBridge\Redis\Transport\RedisTransportFactory::class, ['symfony/framework-bundle', 'symfony/messenger'])) {
$container->getDefinition('messenger.transport.redis.factory')->addTag('messenger.transport_factory');View on GitHub (pinned to 698e28026c)
Solutions
- Run `composer require symfony/messenger`, then `php bin/console cache:clear`.
- If Messenger is not wanted, delete the `framework.messenger` section from config/packages/*.yaml and clear the cache.
- Confirm the interface is present: `php -r 'echo interface_exists("Symfony\\Component\\Messenger\\MessageBusInterface") ? "yes":"no";'`.
Example fix
# before
framework:
messenger:
transports:
async: '%env(MESSENGER_TRANSPORT_DSN)%'
# (symfony/messenger missing -> LogicException)
# after
# terminal: composer require symfony/messenger Defensive patterns
Strategy: validation
Validate before calling
// Mirror the extension's own guard before enabling messenger config.
$isMessengerAvailable = interface_exists(\Symfony\Component\Messenger\MessageBusInterface::class);
if (!$isMessengerAvailable) {
throw new \LogicException('Enable symfony/messenger before adding framework.messenger config.');
} Type guard
null
Try / catch
null
Prevention
- In CI run `cache:clear` (or `lint:container`) on a cold cache so missing-component LogicExceptions surface.
- When you remove symfony/messenger, also delete config/packages/messenger.yaml in the same change.
- Use composer 2 runtime autoload checks (`composer dump-autoload --strict`) to detect dropped classes.
When it happens
Trigger: Having a `framework.messenger` config block (transports, buses, routing) without symfony/messenger installed. Triggered during container compilation — `cache:clear`, `warmup`, or any cold boot.
Common situations: Recipe installed the Messenger config but the package was removed or never required; a flex update pulled in the messenger recipe; copy-pasted messenger.yaml from another project; splitting monolith deps without pruning config.
Related errors
- Rate limiter cannot be used within Messenger as the RateLimi
- Scheduler support cannot be enabled as the Scheduler compone
- The Validation middleware is only available when the Validat
- Invalid Messenger configuration: the failure transport "%s"
- Invalid Messenger routing configuration: invalid namespace "
AI-assisted analysis of symfony/symfony@698e28026c (2026-08-06).
Data as JSON: /api/errors/e01970c9da207cf3.
Report an issue: GitHub.