【发布时间】:2020-11-15 00:45:01
【问题描述】:
我按照 Symfony 当前文档来覆盖异常模板: How to Customize Error Pages
在我的 AccesDeniedListener.php 类中我放了:
public function onKernelException(ExceptionEvent $event, string $eventName = null): void
{
$exception = $event->getThrowable();
if (!$exception instanceof AccessDeniedException) {
return;
}
// ... perform some action (e.g. logging)
// optionally set the custom response
$event->setResponse(new Response(null, 403));
// or stop propagation (prevents the next exception listeners from being called)
//$event->stopPropagation();
}
我已经安装了 symfony/twig-pack
在我的模板文件夹中,我添加了 Execption twigs :
我的新树枝终于没有应用
【问题讨论】:
-
你确定你处于 prod 模式(
APP_ENV=prod) 吗?另外请编辑您的帖子并添加error403.html.twig的代码