安装symfony/messenger执行cache:clear脚本触发配置报错
问题场景
尝试安装symfony/messenger组件,前期依赖安装流程可正常运行,待依赖安装完成后,Composer执行Executing script cache:clear环节时抛出错误,安装流程中断。
完整执行日志如下:
./composer.json has been updated Running composer update symfony/messenger Loading composer repositories with package information Updating dependencies Nothing to modify in lock file Installing dependencies from lock file (including require-dev) Nothing to install, update or remove Generating optimized autoload files 78 packages you are using are looking for funding. Use the `composer fund` command to find out more! Run composer recipes at any time to see the status of your Symfony recipes. Executing script cache:clear [KO] [KO] Script cache:clear returned with error code 1 !! !! In ArrayNode.php line 322: !! !! Unrecognized option "reset_on_message" under "framework.messenger". Availab !! le options are "buses", "default_bus", "enabled", "failure_transport", "rou !! ting", "serializer", "transports". !! !! !! Script @auto-scripts was called via post-update-cmd
报错核心为framework.messenger配置节点下存在无法识别的reset_on_message选项,导致缓存清理脚本执行失败。
问题原因
该问题属于典型的版本不兼容问题:
reset_on_message是Symfony 5.4及以上版本为messenger组件新增的配置项,低于该版本的symfony/framework-bundle在解析配置时,无法识别这个配置字段,会直接触发配置校验报错。- 出现该问题的常见场景是:本地项目使用的Symfony框架版本低于5.4,但安装
symfony/messenger时,Symfony Flex拉取了适配高版本框架的recipe,自动在config/packages/messenger.yaml中写入了reset_on_message配置,最终触发报错。
解决方案
根据自身项目的版本规划二选一处理即可:
- 适配高版本配置(计划升级框架)
将项目内symfony/framework-bundle及相关Symfony核心组件升级到5.4及以上版本,和已安装的messenger组件版本对齐,升级完成后重新执行缓存清理命令即可恢复正常。 - 保留当前框架版本(不升级框架)
- 打开项目配置目录下的
config/packages/messenger.yaml文件,删除文件中reset_on_message相关的配置行并保存。 - 手动执行
php bin/console cache:clear命令验证缓存清理流程可正常运行,后续composer脚本即可正常执行。 - 注意该场景下需要安装和当前框架版本匹配的
symfony/messenger版本,避免后续更新时再次拉取不兼容的高版本配置。
- 打开项目配置目录下的
内容的提问来源于stack exchange,提问作者Dezz H
相关产品推荐
相关产品推荐

