Symfony 2 Debug Toolbar not showing, breaks HTML in dev environment - php

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

Related

Laravel blade tem removes new line

It's not really a big problem, but it is mighty annoying.
When starting creating templates in laravel using blade, everything looks fine. The "master" template/layout gets it's "styling" correct. And by "styling" i mean like correct amount of whitespaces, newlines etc when viewing the source code.
The problem occurs when you know try to extend this master template.
for every #section('<something>') you do know, all newlines is removed from the code, making the source code look fuggly.
Have been searching this phenomenon for a while without finding anything interesting which explains why or maybe a solution to make the source code readable again.
Here is an example if the explanation wasn't good enough:
// master.blade.php
<html>
<head>
<title>Something here</title>
</head>
<body>
#yield('content')
</body>
</html
Alright, this will look exactly like this in the source code. Let's make a another template which extends this.
// home.blade.php
#extends('master')
#section('content')
<h1>Welcome</h1>
<p>This is my homepage</p>
#endsection
This will first of inherit the parent, and replace #yield('content') with:
<h1>Welcome</h1> <p>This is my homepage</p>
Is there any explanation at all why this happens?
For longer sub-templates reading the source code is a living hell. Best way to see the "source code" is to see the generated one in inspect element, which also is just the live code, and not the first generated.
- Sligthly annoyed developer
I believe this is up to Laravels way of handling views. Every blade-view you create in resources/views will be "translated" to PHP. This line in your code for example:
#yield('content')
will be translated to
<?php echo $__env->yieldContent('content'); ?>
you can easely check for yourself by checking all files at storage/framework/views/. This are the files Laravel will include to build the "real" HTML website. Note, that all tab-stops made in .blade.php views are replaced with 4 spaces. And there are this ugly intendations.

IE not loading properly only the first time

I have an application that works perfectly in Chrome,Firefox and Safari, but when I load it on IE happens a strange thing: all the page is loaded on the left side and after one or two refresh it loads properly.
Here are two descriptive images:
And the second time (after one or more refresh) IE loads it like this:
Does anyone know why is IE having this behaviour?
Thank you.
I found the problem, it was quite simple.
I was calling my 'functions.php' as the very first code line (even before <!DOCTYPE html...). This file includes some javascripts function that CAN'T be loaded before <!DOCTYPE html (better between <head></head> tags).
Once I placed them between <head> tags the page is loading properly.
Thank you for the hints.

codeigniter letter at start of every page

I'm working on a website, which I have temporarily hosted here.
You'll notice the mystery letter 'a' I'm getting at the start of every page. I've gone through all the php files (controllers, views, models) and cannot locate where this letter is coming from. Another curiosity is that all the head content is not residing in the head tags when inspected with Firebug. It appears in the body tags, however it still functions correctly. Are these two issues related?
The only thing I have found from searching the internet is that perhaps some files have been saved as ANSI instead of UTF-8. I've tried 'saving as' all my php files as UTF-8 using my editor, but it is a very slow process. Any help debugging this situation would be appreciated.
EDIT- thanks for your response, #erman-belegu. It doesn't seem to be in any controller. For instance, I've set up a 404 redirect, with its own controller and view. The view looks like this:
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="No Page">
</head>
<body>
<h1>No page dude.</h1>
</body>
</html>
But when inspected with firebug, it looks like this:
<html>
<head></head>
<body>
a
<meta content="No Page" name="description">
<h1>No page dude.</h1>
</body>
</html>
I have encoded everything using UTFCast, and am still experiencing the same issue. Any help welcomed.
You see the head inside the body tag because the mysterious "a" is the first character of your output. It's put inside the body tag by the rendering engine of your browser, or by firebug.
If you find the cause of your "a" - almost certainly some content outside PHP tags - the head will return to normal in firebug.
Searching for the "a" is tricky.. I'm not sure how large your codebase is, but I'd say start by exiting the process right before output is sent. You should see only the "a". Then move the exit step by step untill your "a" disappears, and you'll find it.
Check your controllers at start or maybe any print somewhere. Check all your code on these pages because you print these "a ".
Also use UTF-8 without BOM. But, I think that you print it accidentally and dont think that this happens for any other reasons.

The <title> tag becomes empty on my homepage

I'm having some weird problem with my <title> tag on my homepage (the problem occurs only on this page). The title does appear and after some refresh disappear (meaning I have <title>Homepage</title> and then <title></title>)
The problem occurs only on my production server. There's no problem on dev servers.
The problem seems to be resolved if I do create another configuration mode. For instance, I tried with my bypassmode.php (a copy from index.php but with new values: prod => bypass in my app.yml & doctrine.yml).
When I edit on production the view.yml to change title and then I ./symfony cc, it works again but disappear after a refresh. Same as when I do add the $response->setTitle('Homepage'); directly in the action.
I've taken a look at the cache file ./cache/frontend/prod/config/modules_home_config_view.yml.php but the title is set correctly.
I'm running out of ideas... Any suggestions ?
EDIT: As suggested below, I moved my <title> the closest possible to the <head> but it did not change anything.
After further investigation in function include_title(), is it possible that sfContext::getInstance()->getResponse()->getTitle(); might be undefined ? May APC be a problem ?
I'm considering editing AssetHelper.php:
function include_title()
{
$title = sfContext::getInstance()->getResponse()->getTitle();
// Adding some ugly patch here
if (empty($title))
$title = "Default title for my homepage";
// End nasty patch
echo content_tag('title', $title)."\n";
}
But this is so dirty that I wish I can find any other cleaner solution...
The main cause for this is if you're using HTTP/1.1 and the Transfer-Encoding is chunked. If the <title> tag is not one of the very first things in the <head>, the chunking may cause the browser to get lost.
Try moving the <title> tag closer to the top of the <head>.

Javascript in CakePHP

I had one page in Views in CakePHP, it have normal javascript block,
Just inserted:
<script language="JavaScript" type="text/javascript">
---code---
</script>
Inside page, and it was all working okay...
But now... It doesn't show...
How can I change configuration or something to enable showing javascript blocks without CakePHP commands.
Javascript needs data from that page so I can't use outer file,
and it's too long to use $javascript->codeBlock
Is there any way to reconfigure stupid CakePHP to start showing those blocks?
Some files are showing javascript, and it's working all okay, but some of them won't show...
Please help...
If you mean that you want to view the code when the page is displayed, try surrounding it with <pre>...</pre>
If you mean you want the browser to process the code, then provided you are
actually going to that view file and
the code isn't commented out (<!-- ... --> or <?php /* ?> ... <?php */ ?> etc.) and
the code isn't being obliviated by a php conditional (if ... then ... else... endif)
then it will be there. Try Firefox ctrl-u to view the source.
Also try posting the view code here so that we can give you some sort of informed solution.

Categories