我刚刚将Symfony 2.7页面更新为2.8 . 除了Symfony本身之外,还更新了许多其他软件包(例如 FOSUserBundleFOSRestBundleDoctrine 等) .

更新后,我的 CustomExceptionController 不再起作用了 . 像404或500这样的错误显示默认的异常页面而不是我的自定义页面 . 在更新之前我的 CustomExceptionController 没有任何问题 .

这是配置:

// app/config/config.yml
...
twig:
    exception_controller:  app.exception_controller:showAction


// src/MyAppBundle/Resources/config/services.yml
app.exception_controller:
    class: MyAppBundle\Controller\CustomExceptionController
    arguments: ['@twig', '%kernel.debug%', "@translator.default" ]


// src/MyAppBundle/Controller/CustomExceptionController.php
use Symfony\Component\Debug\Exception\FlattenException;    
//use Symfony\Component\HttpKernel\Exception\FlattenException;

class CustomExceptionController extends ExceptionController {   

protected $translator;

public function __construct(\Twig_Environment $twig, $debug, Translator $translator) {
    parent::__construct($twig, $debug);
    $this->translator = $translator;
}

public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null) {
    ...
}

CustomExceptionController 配置中唯一的变化是使用

use Symfony\Component\Debug\Exception\FlattenException

代替

use Symfony\Component\HttpKernel\Exception\FlattenException

(自Symfony 2.3以来已弃用) . 但是问题是一样的,当它改回 ..\HttpKernel\... 类时也是如此 .

据我所知, CustomExceptionController 的配置没有其他变化 . 配置与Symfony docs完全相同 .

知道什么可能是错的吗?