我想让网页调试栏出现在Symfony 2.8中,而且我无法让它工作。Symfony2调试工具栏没有注入Symfony 2.8
我的模板有一个结束标记。此外WebDebugToolbarListener被调用,但中止在此条件下:
if (self::DISABLED === $this->mode
|| !$response->headers->has('X-Debug-Token')
|| $response->isRedirection()
|| ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html'))
|| 'html' !== $request->getRequestFormat()
|| false !== stripos($response->headers->get('Content-Disposition'), 'attachment;')
) {
return;
}
$this->injectToolbar($response, $request);
我调试,发现“X-调试令牌”永远不会包含在报头。这就是为什么不会调用injectToolbar方法的原因。当我评论的特定行|| !$response->headers->has('X-Debug-Token')
工具栏会显示出来,但是我收到异常:
“参数‘令牌’路由‘_wdt’必须匹配‘[^ /] +’(””中给出)到 生成相应的URL。“
此外,它显然是处理这个问题的错误方式。
我在做什么错?我没有想法。
以下是我已经配置:
#config_dev.yml
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: true }
web_profiler:
toolbar: true
intercept_redirects: false
position: bottom
//app_dev.php
Debug::enable();
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
//AppKernel.php
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
#routing_dev.yml
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
有趣。我没有一个2.8版本的方便,但我的开箱3.2应用程序工作正常,没有启用:true – Cerad
是的,我错了,关键是将'only_exceptions'设置为false :) – Atan