簡體   English   中英

沒有注入Symfony2調試工具欄Symfony 2.8

[英]Symfony2 debug toolbar is not injected Symfony 2.8

我試圖使Web調試欄出現在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-Debug-Token”。 這就是為什么永遠不會調用injectToolbar方法的原因。 當我評論特定行|| !$response->headers->has('X-Debug-Token') || !$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

顯然,我必須顯式地啟用探查器(設置X-Debug-Token)。 RTM取勝。 我過去從未這樣做過。

關鍵是設置only_exceptions: false 否則,探查器將不會收集任何數據,也不會設置X-Debug-Token,因此工具欄將不會附加。 過去,我將此標志設置為true,因為我的緩存目錄增長非常快。

默認情況下,對於開發和測試環境,已enabled標志設置為true。

#config_dev.yml
framework:
    router:
        resource: "%kernel.root_dir%/config/routing_dev.yml"
        strict_requirements: true
    profiler: { only_exceptions: false }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM