我想讓網頁調試欄出現在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