弃用 symfony 解决方案

Mik*_*kel 4 php symfony

将symfony更新到4.4版后如何解决这个问题

[2020-01-03 08:46:27] php.INFO: User Deprecated: The "twig.exception_listener" service is deprecated since Symfony 4.4. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The \"twig.exception_listener\" service is deprecated since Symfony 4.4. at /var/www/api/var/cache/prod/Container8sfHI7P/getTwig_ExceptionListenerService.php:9)"} []
[2020-01-03 08:46:27] php.INFO: User Deprecated: The "Symfony\Component\HttpKernel\EventListener\ExceptionListener" class is deprecated since Symfony 4.4, use "ErrorListener" instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The \"Symfony\\Component\\HttpKernel\\EventListener\\ExceptionListener\" class is deprecated since Symfony 4.4, use \"ErrorListener\" instead. at /var/www/api/vendor/symfony/http-kernel/EventListener/ExceptionListener.php:25)"} []
[2020-01-02 05:28:12] php.INFO: User Deprecated: Auto-injection of the container for "\App\Controller\InstallController" is deprecated since Symfony 4.2. Configure it as a service instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: Auto-injection of the container for \"\\App\\Controller\\InstallController\" is deprecated since Symfony 4.2. Configure it as a service instead. at /var/www/api/vendor/symfony/framework-bundle/Controller/ControllerResolver.php:64)"} []
Run Code Online (Sandbox Code Playgroud)

Bar*_*art 6

我发现这个问题也很难解决。它不会由 Composer 更新自动解决,因为它是配置的一部分,仅在您第一次需要包时才从它的配方中应用。

您必须更改 4.4 的默认配置中也更改的三项内容(我使用下面的点表示嵌套键):

  • config/packages/twig.yamltwig.exception_controller: null
  • config/routes/dev/twig.yaml改变_errors.resource@FrameworkBundle/Resources/config/routing/errors.xml
  • 重命名config/routes/dev/twig.yamlconfig/routes/dev/framework.yaml