Symfony 2 调试工具栏未显示,在开发环境中破坏 HTML [英] Symfony 2 Debug Toolbar not showing, breaks HTML in dev environment

查看:28
本文介绍了Symfony 2 调试工具栏未显示,在开发环境中破坏 HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I really need your help with this. I don't know what I've done to break the Symfony 2 toolbar. The debug tool bars stop showing and when I look at the source code of the page, I can see something like this:

<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>hello</h1>
<div id="sfwdt  

and then the page terminates. This page I set up for debugging use the simplest HTML layout without using any variable and is not behind a firewall. I simply want to get the debugger toolbar showing. It looks like the debugger did try to load but for some reason it teminate at:

<div id="sfwdt

and breaks the entire page. If I turn the debugger off, the ending tag of the body and html come back.

I've searched for the occurrence of 'sfwdt' and it looks like it is from one of the twig templates of the profiler, however, when I modify that template to try things out, nothing change. Any one can point me to the right direction what's going wrong ?

And there's no error message found. I've comment out all services and keep it to the minimum, still no luck.

AppBundle/Resources/views/layout2.html.twig

<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>hello</h1>
</body>
</html>

AppBundle/Resources/views/Default/index.html.twig

{% extends "AppBundle::layout2.html.twig" %}

解决方案

Sorry, I finally found the issue.

One of the custom bundles registers the kernel.response event and try adding a content-length header to the response. The content-length does not take into account the extra code for the debugger bar and it trims out the extra content added for the debugger toolbar !! and it explains why the page always terminates at <div id="sfwdt, because it takes the same number characters as body and html end tags

这篇关于Symfony 2 调试工具栏未显示,在开发环境中破坏 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆