Saturday, December 29, 2018

php - Setting Up ChromePhp For Wordpress Using Xampp



I found ChromePhp to help with my PHP debugging woahs and installed the related 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 of xampp using:



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


That didn't seem to work I kept getting errors like the one below whenever I tried to include the file and output a ChromePhp::log("message")





Warning: Cannot modify header information - headers already sent by (output started at D:\htdocs\ask.ca\wp-admin\menu-header.php:91) in D:\htdocs\ask.ca\wp-includes\ChromePhp.php on line 385




So then I tried a similar approach in my windows path, with the same result.



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



include( dirname(__FILE__) . '/php/ChromePhp.php' );

ChromePhp::log("Hello World");


But I still get the same error??? Can anyone explain the ABC's of getting ChromePhp to work? I say ABC's since apparently even though I read ChromePhp's website instructions (and couple other peoples in order to get this to work) which are very short and I thought simple, I still need a more Sesame Street explanation.


Answer



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


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...