Setting up ChromePhp for Wordpress with Xampp

I found ChromePhp to help with my PHP debugs and install the corresponding Chrome plugin, but I can't seem to get it to work. I originally put it in a folder in my redirected htdocs and added that to my PHP path in php.ini xampp using:

; Windows: "\path1;\path2"
include_path = ".;C:\xampp\php\PEAR;D:\htdocs\includes"

      

It didn't seem to work. I kept getting errors like below whenever I tried to include a file and it outputChromePhp::log("message")

Warning. Unable to change header information - already sent headers (output starts with D: \ htdocs \ ask.ca \ wp-admin \ menu-header.php: 91) to D: \ htdocs \ ask.ca \ wp -includes \ ChromePhp.php on line 385

So, I tried a similar approach on my Windows path with the same result.

Finally, I went completely local and tried to include the ChromePhp.php file in my plugin using:

include( dirname(__FILE__) . '/php/ChromePhp.php' );
ChromePhp::log("Hello World");

      

But I still get the same error ??? Can anyone explain ABC on how to get ChromePhp to work? I am talking about ABC because apparently, although I read the instructions on the ChromePhp website (and a couple of other people to get this to work) which are very short and I thought it was simple, I still need to clarify more explanations on the topic Sesame.

+3


source to share


6 answers


I am a ChromePHP developer. You see this problem because the output has already started on the page. Once you hear something, you can no longer set titles.

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



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

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

+5


source


If you cannot change your code to get Chrome PHP to work, you can use the PHP Console . It works even when exiting. Messages are sent to the Chrome console and pop up. You can customize the popup from the right-click context menu.



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

+1


source


If you just want to debug the data in the console and not the screen.

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

      

+1


source


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

Download this plugin and activate it.

Use any function (below in the example) to output anything to the 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

+1


source


it worked for me.

Add @ to line 378 in ChromePhp.php:

Before →

header (self :: HEADER_NAME. ':'. $ this → _ encode ($ data));

After →

@header (self :: HEADER_NAME. ':'. $ this → _ encode ($ data));

0


source


I tried @Ravs plugin but couldn't get it to work for life. Path errors persisted, even though the path was in order.

After maxing out and browsing other comments on the internet, I took a slightly longer route by simply dumping 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();
?>

      

0


source







All Articles