gpt4 book ai didi

php - 为什么升级到Symfony 4.4之后,我不再获得错误预览页面?

转载 作者:行者123 更新时间:2023-12-03 07:52:14 24 4
gpt4 key购买 nike

我刚刚将一个项目从Symfony 4.3更新到了4.4。更新后,当我遇到错误时,显示的页面是带有“糟糕!发生错误!”的生产错误页面,而不是包含所有错误跟踪的dev错误页面。

另外,探查器不会记录错误页面,我可以在探查器中看到所有请求,但看不到有错误的请求。

如果查看日志(我正在使用docker),则可以看到php错误:

$ docker logs php
172.21.0.3 - 17/Jun/2020:09:50:53 +0000 "GET /index.php" 500
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "NOTICE: PHP message: PHP Fatal error: Uncaught Twig\Error\SyntaxError: Unexpected "}". in /app/templates/professionals/artists/list.html.twig:26"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "Stack trace:"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#0 /app/vendor/twig/twig/src/Lexer.php(292): Twig\Lexer->lexExpression()"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#1 /app/vendor/twig/twig/src/Lexer.php(186): Twig\Lexer->lexVar()"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#2 /app/vendor/twig/twig/src/Environment.php(542): Twig\Lexer->tokenize(Object(Twig\Source))"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#3 /app/vendor/twig/twig/src/Environment.php(595): Twig\Environment->tokenize(Object(Twig\Source))"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#4 /app/vendor/twig/twig/src/Environment.php(408): Twig\Environment->compileSource(Object(Twig\Source))"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#5 /app/vendor/twig/twig/src/Environment.php(381): Twig\Environment->loadClass('__TwigTemplate_...', 'professionals/a...', NULL)"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#6 /app/vendor/twig/twig/src/Environment.php(359): Twig\Environment->loadTemplate('professionals/a...')"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#7 /app/vendor/symfony/twig-bridge/TwigEngine.php(135): Twig\Environment->load('professionals/a...')"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#8 /app/vendor/symfony/twig-bridge/TwigEngine.php(54): Symfony\Bridge\Twig\TwigEngine->load(..."
.env文件设置为 APP_ENV=dev

最佳答案

在Symfony 4.4中,ErrorHandler组件that replaced the Debug component被释放。

这样,某些文件的位置已更改。

您需要找到config/routes/dev/twig.yaml,并删除以下几行:

# config/routes/dev/twig.yaml
_errors:
resource: '@TwigBundle/Resources/config/routing/errors.xml'
prefix: /_error

在其位置上,使用以下内容创建一个新文件 config/routes/dev/framework.yaml:
# config/routes/dev/framework.yaml
_errors:
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
prefix: /_error

这样可以在开发过程中恢复旧的错误预览页面。

关于php - 为什么升级到Symfony 4.4之后,我不再获得错误预览页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62426258/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com