Symfony 4.1 自定义树枝错误模板

Symfony 4.1 Custom twig error template

我正在尝试根据 the symfony documentation

覆盖 twig html 错误模板

所以我试图通过在 'templates/bundles/TwigBundle/Exception' 中创建以下文件来覆盖其他第三方包的视图:

然而,当我在生产模式下触发 404 错误时,会显示默认的 html twig 错误模板。

在开发模式下使用 /_error/{statusCode} 路径进行测试可以正确显示我的自定义模板。

编辑:我发现这是 FriendsOfSymfony/FOSRestBundle 的问题。使用 composer require friendsofsymfony/rest-bundle dev-master 解决了问题