我遇到了这个问题:当我想要替换twig bundle的默认错误页面时(以下是每个人都可以看到here所请求的方法),只要我和#我就会安静下来39;我没有创建通用error.html.twig
或error404.html.twig
。但奇怪的是,我的error403.html.twig
可以作为一个奇迹。
我使用OS X Kaleidoscope将我的错误模板相互比较,并且几个差异是完全良性的。
我将您的error.html.twig作为实例提供给您:
{% extends (is_mobile() and not is_tablet())?
':Mobile:layout.html.twig'
:
':Full:layout.html.twig'
%}
{% block title %}
Une erreur est survenue : {{ status_text }}
{% endblock %}
{% block content %}
{% endblock %}
{% block footer %}
<div id="h1-error">Aie !<br>Le serveur ne répond pas</div>
{% set table=[
["*","*","*","*","*","*","*","*","*"],
["*","*","*","*","5","0","0","*","*"],
["*","*","*","*","*","*","*","*","*"],
["*","*","A","U","C","U","N","E","*"],
["*","*","*","*","*","*","*","*","*"],
["*","*","*","*","*","*","*","*","*"],
["*","*","*","*","*","*","*","*","*"],
["*","R","É","P","O","N","S","E","*"],
["*","*","*","*","*","*","*","*","*"]
]
%}
<div id="table">
<table border-collapse="separate">
{% for i in 0..8 %}
<tr>
{% for j in 0..8 %}
{% if table[i][j]!='*' %}
<td class="special">
<span id="symbol">
{{table[i][j]}}
</span>
</td>
{% else %}
<td>
<span id="symbol">
{{random('QWERTZUIOPLKJHGFDSAYXCVBNM')}}
</span>
</td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</table>
</div>
<div id="backHome">
<br>
<a class="mr-btn mr-btn-primary" id="back-button" href="{{path('mr_platform_home')}}">
Retour à l'accueil
</a>
<br>
</div>
{{ parent() }}
{% endblock %}
此外,这些文件的路径是正确的:app/Resources/TwigBundle/views/Exception/[file]
最后一点,我的prod日志如下,当我尝试像http://localhost:8888/AugustProject/web/test这样的测试网址时(我正在本地服务器上工作,但同样的问题发生在远程服务器上) ):
request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /test"" at /Applications/MAMP/htdocs/MamyRoom/var/cache/prod/classes.php line 2774 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /test\" at /Applications/MAMP/htdocs/MamyRoom/var/cache/prod/classes.php:2774, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0): at /Applications/MAMP/htdocs/MamyRoom/var/cache/prod/appProdUrlMatcher.php:1000)"} []
...让人们认为代码不是bug的来源(?)
我错过了什么步骤?
非常感谢,提前!