Rém*_*anc 4 symfony twig symfony5
我正在尝试在我的 Symfony 5 项目上自定义错误模板。我想使用 TwigBundle 错误渲染器,因为它似乎是最轻的解决方案。
所以我遵循了这个文档:https://symfony.com/doc/current/controller/error_pages.html#overriding-the-default-error-templates
当我运行此命令时,TwigBundle 看起来已正确安装:composer require symfony/twig-pack没有任何错误。
error.html.twig但现在我在 TwigBundle 的任何文件夹中都找不到任何内容,尤其TwigBundle/Exception/是在文档中建议的文件夹(甚至不存在)中。
也许这不是我安装的好的“TwigBundle”?或者也许有更好、更轻的解决方案来自定义错误页面?
您需要覆盖错误模板 \nLike ->\n在您的模板文件夹中,您创建这样的文件夹 \ntemplates -> Bundles->TwigBundle->Exception\n在异常文件夹中,您可以为每种类型的错误创建一个文件,例如 \nerror404 .html.twig OR error403.html.twig\nerror.html.twig # 所有其他 HTML 错误(包括 500)
\n\ntemplates/\n \xe2\x94\x94\xe2\x94\x80 bundles/\n \xe2\x94\x94\xe2\x94\x80 TwigBundle/\n \xe2\x94\x94\xe2\x94\x80 Exception/\n \xe2\x94\x9c\xe2\x94\x80 error404.html.twig\n \xe2\x94\x9c\xe2\x94\x80 error403.html.twig\n \xe2\x94\x94\xe2\x94\x80 error.html.twig # All other HTML errors (including 500)\nRun Code Online (Sandbox Code Playgroud)\n\n请注意,此错误页面将仅在 prod 中显示
\n\n来源: https: //symfony.com/doc/current/controller/error_pages.html
\n| 归档时间: |
|
| 查看次数: |
4205 次 |
| 最近记录: |