Setting Up ChromePhp For Wordpress Using Xampp

跟風遠走 提交于 2019-12-05 23:18:12

I'm the developer of ChromePHP. You are seeing this problem because output has already started on the page. As soon as you echo something out you can no longer set headers.

See this related ticket:
https://github.com/ccampbell/chromephp/issues/15

I'm not sure about the internal workings of Wordpress, but basically you have to either log the information before any output has been sent to the page, or you have to use output buffering to prevent output from being sent and then flush the buffer after you are done logging.

Also:
http://wordpress.org/support/topic/error-cannot-modify-header-information-2

If you're just looking to debug data in the console rather than on screen.

// Debug $data will display in console
function console_debug( $data ) {
    $data = json_encode($data);
    echo "<script>console.dir($data)</script>";
}

If you can't change your code to get Chrome PHP to work, you can use PHP Console. It works even if output has started. Messages go to Chrome's console and a pop-up. You can configure the pop-up through right-click context menu.

No offense ChromePHP. I also appreciate what people like the authors of ChromePHP and PHP Console are doing.

You can use WP Chrome Logger plugin, which is based on chromephp.

Download this plugin and activate it.

Use any function ( below in example ) to output anything in chrome console ( put these functions in plugin file or functions.php ).

ChromePhp::log('Hello console!');
ChromePhp::log($_SERVER);
ChromePhp::warn('something went wrong!');

Tested with WP 3.8

this worked for me.

Add a @ in line 378 in ChromePhp.php:

Before->

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

After ->

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

I tried @Ravs plugin but could not for the life of me get it to work. Kept getting path errors despite the fact the path was fine.

After peaking inside and looking at other comments on the web, I took the slightly more long winded route of simply throwing ChromePhp.php into the same directory as the file and adding

<?php
ob_start(); 
include 'ChromePhp.php';

...
ChromePhp::log('long winded but it works');
...

ob_flush();
?>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!