我的控制器中有这个:
if(some stuff) {
throw $this->createNotFoundException('message');
}
当我在 dev env 中测试它时,我得到 Symfony 的页面,告诉我的文本检测到异常,但我无法在 prod env 中测试它:( 我运行它php app/console cache:clear --env=prod --no-debug
,然后只在 URL 中替换app_dev.php
工具app.php
栏和 Symfony 的错误页面停留。
我创建了这个文件 - app/Resources/TwigBundle/views/Exception/error.html.twig
. 那么它会在产品中渲染吗?
这是在里面:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>An Error Occurred: {{ status_text }}</title>
</head>
<body>
<h1>Oops! An Error Occurred</h1>
<h2>The server returned a "{{ status_code }} {{ status_text }}".</h2>
</body>
</html>
我应该在哪里为status_code
andstatus _text
赋值?或者它们是从异常中获取的?
所以总的来说,我想要做的是当我的控制器操作中的条件为真时,我的自定义错误页面将显示在 prod env 中。我是否已经成功了,如果没有,如何制作以及如何在 prod env 中查看结果?