英文:
Deprecate symfony solve
问题
如何解决在将Symfony升级到4.4版本后出现的问题:
[2020-01-03 08:46:27] php.INFO: 用户已弃用:自Symfony 4.4起,"twig.exception_listener"服务已弃用。 {"exception":"[object] (ErrorException(code: 0): 用户已弃用:自Symfony 4.4起,"twig.exception_listener"服务已弃用。位于/var/www/api/var/cache/prod/Container8sfHI7P/getTwig_ExceptionListenerService.php:9)"} []
[2020-01-03 08:46:27] php.INFO: 用户已弃用:自Symfony 4.4起,"Symfony\Component\HttpKernel\EventListener\ExceptionListener"类已弃用,请改用"ErrorListener"。 {"exception":"[object] (ErrorException(code: 0): 用户已弃用:自Symfony 4.4起,"Symfony\Component\HttpKernel\EventListener\ExceptionListener"类已弃用,请改用"ErrorListener"。位于/var/www/api/vendor/symfony/http-kernel/EventListener/ExceptionListener.php:25)"} []
[2020-01-02 05:28:12] php.INFO: 用户已弃用:自Symfony 4.2起,为"\App\Controller\InstallController"自动注入容器已弃用。请将其配置为服务。 {"exception":"[object] (ErrorException(code: 0): 用户已弃用:自Symfony 4.2起,为"\App\Controller\InstallController"自动注入容器已弃用。请将其配置为服务。位于/var/www/api/vendor/symfony/framework-bundle/Controller/ControllerResolver.php:64)"} []
请注意,我只翻译了代码部分,没有包括其他内容。
英文:
How to solve this problems after update symfony to ver 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)"} []
答案1
得分: 6
我发现这个问题也很棘手。它不会在composer更新时自动解决,因为它是仅在首次要求包时才从其recipe应用的配置的一部分。
您需要更改三个与默认配置中的更改相同的内容(我在下面使用点表示嵌套键):
- 在
config/packages/twig.yaml
中添加twig.exception_controller: null
- 在
config/routes/dev/twig.yaml
中将_errors.resource
更改为@FrameworkBundle/Resources/config/routing/errors.xml
- 将
config/routes/dev/twig.yaml
重命名为config/routes/dev/framework.yaml
英文:
I found this one tricky to solve as well. It's not automatically resolved by a composer update because it's part of the configuration that's only applied from it's recipe when you require a package for the first time.
You'll have to change three things that are also changed in the default configuration for 4.4 (I used dots below to indicate nested keys):
- in
config/packages/twig.yaml
addtwig.exception_controller: null
- in
config/routes/dev/twig.yaml
change the_errors.resource
to@FrameworkBundle/Resources/config/routing/errors.xml
- rename
config/routes/dev/twig.yaml
toconfig/routes/dev/framework.yaml
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论