配方升级后的symfony路由错误

问题描述

将symfony / framework-bundle配方从4.4升级到5.1版本后,出现此错误

Argument 2 passed to Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator::__construct() must be an instance of Symfony\Component\Routing\Loader\PHPFileLoader,instance of Symfony\Component\Routing\Loader\AnnotationFileLoader given,called in /app/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.PHP on line 176

食谱进行了以下更改:

enter image description here

enter image description here

此外,我发现是否从vendor/symfony/routing/Loader/Configurator/RoutingConfigurator.PHP的构造函数删除PHPLoader typehint。一切开始工作

也许我忘记了什么?或者我如何在不更改供应商文件的情况下使它工作?

symfony残片:

composer show --installed|grep symfony
You are using the deprecated option "installed". Only installed packages are shown by default Now. The --all option can be used to show all packages.
symfony/asset                        v5.1.3  Symfony Asset Component
symfony/browser-kit                  v5.1.3  Symfony browserKit Component
symfony/cache                        v5.1.3  Symfony Cache component with PSR-6,PSR...
symfony/cache-contracts              v2.1.3  Generic abstractions related to caching
symfony/config                       v5.1.3  Symfony Config Component
symfony/console                      v5.1.3  Symfony Console Component
symfony/css-selector                 v5.1.3  Symfony CssSelector Component
symfony/debug-bundle                 v5.1.3  Symfony DebugBundle
symfony/debug-pack                   v1.0.8  A debug pack for Symfony projects
symfony/dependency-injection         v5.1.3  Symfony DependencyInjection Component
symfony/deprecation-contracts        v2.1.3  A generic function and convention to tr...
symfony/doctrine-bridge              v5.1.3  Symfony Doctrine Bridge
symfony/dom-crawler                  v5.1.3  Symfony DomCrawler Component
symfony/dotenv                       v5.1.3  Registers environment variables from a ...
symfony/error-handler                v5.1.3  Symfony ErrorHandler Component
symfony/event-dispatcher             v5.1.3  Symfony Eventdispatcher Component
symfony/event-dispatcher-contracts   v2.1.3  Generic abstractions related to dispatc...
symfony/expression-language          v5.1.3  Symfony ExpressionLanguage Component
symfony/filesystem                   v5.1.3  Symfony Filesystem Component
symfony/finder                       v5.1.3  Symfony Finder Component
symfony/flex                         v1.9.1  Composer plugin for Symfony
symfony/form                         v5.1.3  Symfony Form Component
symfony/framework-bundle             v5.1.3  Symfony FrameworkBundle
symfony/http-client                  v5.1.3  Symfony HttpClient component
symfony/http-client-contracts        v2.1.3  Generic abstractions related to HTTP cl...
symfony/http-foundation              v5.1.3  Symfony HttpFoundation Component
symfony/http-kernel                  v5.1.3  Symfony HttpKernel Component
symfony/intl                         v5.1.3  A PHP replacement layer for the C intl ...
symfony/lock                         v5.1.3  Symfony Lock Component
symfony/mailer                       v5.1.3  Symfony Mailer Component
symfony/maker-bundle                 v1.20.0 Symfony Maker helps you create empty co...
symfony/mime                         v5.1.3  A library to manipulate MIME messages
symfony/monolog-bridge               v5.1.3  Symfony Monolog Bridge
symfony/monolog-bundle               v3.5.0  Symfony MonologBundle
symfony/options-resolver             v5.1.3  Symfony OptionsResolver Component
symfony/PHPunit-bridge               v5.1.3  Symfony PHPUnit Bridge
symfony/polyfill-intl-grapheme       v1.18.1 Symfony polyfill for intl's grapheme_* ...
symfony/polyfill-intl-normalizer     v1.18.1 Symfony polyfill for intl's normalizer ...
symfony/polyfill-PHP80               v1.18.1 Symfony polyfill backporting some PHP 8...
symfony/process                      v5.1.3  Symfony Process Component
symfony/profiler-pack                v1.0.5  A pack for the Symfony web profiler
symfony/property-access              v5.1.3  Symfony PropertyAccess Component
symfony/property-info                v5.1.3  Symfony Property Info Component
symfony/proxy-manager-bridge         v5.1.3  Symfony ProxyManager Bridge
symfony/routing                      v5.1.3  Symfony Routing Component
symfony/security-bundle              v5.1.3  Symfony SecurityBundle
symfony/security-core                v5.1.3  Symfony Security Component - Core Library
symfony/security-csrf                v5.1.3  Symfony Security Component - CSRF Library
symfony/security-guard               v5.1.3  Symfony Security Component - Guard
symfony/security-http                v5.1.3  Symfony Security Component - HTTP Integ...
symfony/service-contracts            v2.1.3  Generic abstractions related to writing...
symfony/stopwatch                    v5.1.3  Symfony Stopwatch Component
symfony/string                       v5.1.3  Symfony String component
symfony/swiftmailer-bundle           v3.4.0  Symfony SwiftmailerBundle
symfony/templating                   v5.1.3  Symfony Templating Component
symfony/test-pack                    v1.0.6  A pack for functional and end-to-end te...
symfony/translation                  v5.1.3  Symfony Translation Component
symfony/translation-contracts        v2.1.3  Generic abstractions related to transla...
symfony/twig-bridge                  v5.1.3  Symfony Twig Bridge
symfony/twig-bundle                  v5.1.3  Symfony TwigBundle
symfony/validator                    v5.1.3  Symfony Validator Component
symfony/var-dumper                   v5.1.3  Symfony mechanism for exploring and dum...
symfony/var-exporter                 v5.1.3  A blend of var_export() + serialize() t...
symfony/web-profiler-bundle          v5.1.3  Symfony WebProfilerBundle
symfony/webpack-encore-bundle        v1.7.3  Integration with your Symfony app & Web...
symfony/yaml                         v5.1.3  Symfony Yaml Component

解决方法

要解决此问题,应将其添加到配置中:

sensio_framework_extra:
    router:
        annotations: false

修正已合并https://github.com/symfony/symfony/pull/38226