Symfony 2-在测试环境中获取错误而不是调试页面/如何在测试环境中将调试设置为false(Twig ExceptionController)?

Symfony 2-在测试环境中获取错误而不是调试页面/如何在测试环境中将调试设置为false(Twig ExceptionController)?,symfony,Symfony,我想获得错误页面(在应用程序的异常为trhown之后),而不是测试环境上的调试页面 我跟踪了细枝束代码,答案在findTemplate()方法中的Symfony\Bundle\TwigBundle\Controller\ExceptionController类中。 这里我复制了选择模板的负责代码片段 $name = $debug ? 'exception' : 'error'; if ($debug && 'html' == $format) {

我想获得错误页面(在应用程序的异常为trhown之后),而不是测试环境上的调试页面

我跟踪了细枝束代码,答案在findTemplate()方法中的Symfony\Bundle\TwigBundle\Controller\ExceptionController类中。 这里我复制了选择模板的负责代码片段

    $name = $debug ? 'exception' : 'error';
    if ($debug && 'html' == $format) {
        $name = 'exception_full';
    }
这段代码没有问题。关键是,对于我的测试环境,我不能将ExceptionController$debug变量设置为false

基于,在config_test.yml中将调试参数设置为false就足够了

twig:
  debug:       false
    <service id="twig.controller.exception" class="%twig.controller.exception.class%">
        <argument type="service" id="twig" />
        <argument>%kernel.debug%</argument>
    </service>
这不管用

我已经浏览了Symfony代码,并在供应商/Symfony/Symfony/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml上找到了这个片段配置

twig:
  debug:       false
    <service id="twig.controller.exception" class="%twig.controller.exception.class%">
        <argument type="service" id="twig" />
        <argument>%kernel.debug%</argument>
    </service>


这不是基于环境吗

就像在app_dev.php中一样:

$kernel = new AppKernel('stag', TRUE); #TRUE = debug/dev mode on
$kernel = new AppKernel('stag', FALSE); #FALSE = debug/dev mode off

谢谢你。它应该是基于你所说的,但它就是不起作用。我会继续研究的。