2013-09-22 28 views
1

我試圖從遠程計算機做到這一點,因此app_dev.php是:模板呈現無法獲得的Symfony 2工具欄上顯示網站

<?php 
use Symfony\Component\HttpFoundation\Request; 
use Symfony\Component\Debug\Debug; 
$loader = require_once __DIR__.'/../app/bootstrap.php.cache'; 
Debug::enable(); 
require_once __DIR__.'/../app/AppKernel.php'; 
$kernel = new AppKernel('dev', true); 
$kernel->loadClassCache(); 
$request = Request::createFromGlobals(); 
$response = $kernel->handle($request); 
$response->send(); 
$kernel->terminate($request, $response); 

後,我得到這個:

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
    <meta charset="utf-8"> 
    <title>Title</title> 
    </head> 
    <body> 
     <h1>Give us a toolbar now will you?</h1> 
    </body> 
</html> 

看起來像有效的html,並有一個body元素,但沒有工具欄。

我只有ftp訪問權限,因此將Symfony/app/cache文件夾重命名爲不存在。

我已經證實,app_dev.php執行Debug::enable();$kernel = new AppKernel('dev', true);(添加有引起的誤差的誤差。

我已經證實,有效的HTML產生渲染index.html.twig(不是高速緩存的一個)。我已更名爲緩存目錄。

不知道還有什麼可以檢查有它顯示的工具欄。

回答

5

您必須啓用AppKernel.php

public function registerBundles() 
{ 
    $bundles = ... 

    if (in_array($this->getEnvironment(), array('dev', 'test'))) { 
     $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); 
     ... 
    } 

    return $bundles; 
} 
分析器

並確保您已啓用JavaScript。

+0

謝謝你的回覆,AppKernel看起來像你發佈的那個,WebProfilerBundle在Symfony中,因此是senseo中的DistributionBundle和GeneratorBundle。 JavaScript已啓用,但您可以在生成的響應中看到它並不重要,因爲沒有生成工具欄,即使JavaScript被禁用,工具欄也會顯示在頁面源中。 – HMR

+0

必須啓用Javascript,因爲工具欄是通過javascript加載的。但即使JavaScript被禁用,您仍然正確WebProfilerBundle在標記之前注入了一個佔位符,並且它不在您的HTML中。你可以在這裏看到加載工具欄的條件:https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php#L79。特別檢查你是否在路由文件中設置了'_format:xml'。僅當'_format'被設置爲'html'(默認值)時才加載工具欄。 – J4rmu1