ccampbell / chromephp

class for logging PHP variables to Google Chrome console
http://www.chromelogger.com
1.38k stars 450 forks source link

WordPress theme - headers already sent #15

Closed jancbeck closed 12 years ago

jancbeck commented 12 years ago

Using chromePHP inside a WordPress theme gives me an error of "headers already sent". The problematic line is 385:

header(self::HEADER_NAME . ': ' . $this->_encode($data));

Using ChromePHP in WP is no problem as long as wp_head() isn't called. Is there a known workaround?

ccampbell commented 12 years ago

This is not a bug in my extension. You cannot send headers after output has started.

You can use headers_sent() to determine if headers have already been sent.

You can also use output buffering to delay output so you can still set headers. http://php.net/manual/en/book.outcontrol.php

blowsie commented 11 years ago

I think it would be great if there could be some clear instructions on how to use this with wordpress

StijnDeWitt commented 10 years ago

Use the WP Chrome Logger WordPress plugin. It solves the mentioned problems.

bueltge commented 10 years ago

You can also use the plugin Debug Objects in WordPress. This use Chrome Logger and have also another debugging features.

EvanHerman commented 10 years ago

I have been using this on multiple WordPress projects with no issues. There is no issue related to the debugger and WordPress. It's all a matter of how you are using the debugger and logging your information.

StijnDeWitt commented 10 years ago

If you try to debug a statement at a point where the HTML output has already begun you will get the error mentioned. If output buffering is enabled you will not have a problem.

"There is no issue related to the debugger and WordPress."

I don't think it's a WordPress issue per se, but a generic PHP issue. As soon as the first HTML has been sent to the client you cannot add more debug statements. WordPress just makes it very easy to do this as you generally write plugins / themes which hook into the main site.

I wonder what setup you are using that you never had any issues? Do you use ob_start() / ob_flush() ? Some setting in Apache?

The very first debug statement I wrote gave me this error right away... Could be a coincidence...

vaskort commented 8 years ago

@StijnDeWitt WP Chrome Logger didn't solve the problems for me