symfony2调试工具栏无法加载

时间:2014-02-08 08:14:59

标签: php symfony controller

当我使用此代码作为控制器但是网站正确加载并且我没有在日志中出现任何错误时,调试工具栏不会加载。

function indexAction(){
        //this configures the $html which is global works correctly
        include "/index.php";

        $response = new Response();     
        $response->setContent( $html );
        $response->setStatusCode(Response::HTTP_OK);
        $response->headers->set('Content-Type','text/html');
        return $response;
}

但是当我使用这段任意代码时它确实有效

function indexAction(){
        $bar = "<html><body>foo : random piece of text</body></html>";
        $response = new Response();

        $response->setContent($bar);
        $response->setStatusCode(Response::HTTP_OK);
        $response->headers->set('Content-Type','text/html');
        return $response;
}

我已经意识到,当我使用第一个代码时,我没有在log中获得_wdt的路由匹配。问题可能出在哪里?

更新:如果我从$ bar中移除body标签,如:

  $bar = "<html>foo: random piece of text</html>"

它也不起作用。我认为它与页面没有正确的HTML标记有关,如symfony2中的eventlistener文档中所述。但是我知道我的页面被正确标记了。还看了之后的源代码。浏览器中的页面问题。这里有什么问题?

1 个答案:

答案 0 :(得分:0)

问题解决了:页面中的HTML标签正在加载包含的空格,例如:而不是看起来听起来没有检测到。

相关问题