PHP server messages

47 views
Skip to first unread message

Pedro Bastos das Neves

unread,
Mar 6, 2017, 5:48:20 AM3/6/17
to Firebug
How to log to the console php server messages? And witch server library to use?
I'm asking this because Firephp is not working.
The crhome logger is the only choice? This one doesn't work well too?
Thanks,

Sebastian Zartner

unread,
Mar 6, 2017, 6:40:55 AM3/6/17
to Firebug
Yes, Chrome Logger is what you need to use.
If you have issues integrating it into your PHP code, you should open an issue for Chrome Logger. If you integrated it into your PHP code, but the output is not shown or incorrectly shown in the DevTools console, you should first read the related documentation. If you then still experience problems, ask on IRC, Twitter or Stack Overflow or file a bug against the DevTools.

Sebastian

Erik Krause

unread,
Mar 6, 2017, 7:44:44 AM3/6/17
to fir...@googlegroups.com
Am 04.03.2017 um 10:21 schrieb Pedro Bastos das Neves:
> The crhome logger is the only choice? This one doesn't work well too?

I've modified chromePHP such that it is a bit more FirePHP-like:
https://github.com/ErikKrause/chromephp

--
Erik Krause

Lawrence San

unread,
Mar 6, 2017, 11:03:58 AM3/6/17
to fir...@googlegroups.com
I don't understand why people are
​now ​
saying you
​_​
have
​_​
to use Chrome Logger
​ to log PHP from Firefox.​ That's not true
. In this discussion list,
​see
 the thread entitled "replacement for firephp (devtools)"
​ from late September to early December 2016 (sorry, I don't know how to link to it). In that thread, Erik, myself, and a couple of others talked about other ways of getting PHP logging in Firefox, without FirePHP. (Although FirePHP was certainly better and I wish it would come back to Firefox.)

Here's the method I use, and it still works:

Set up a separate PHP file in your standard PHP path location. This is originally based on someone else's script (unfortunately I don't know whose, so I can't credit him here), but I made some modifications to simplify it. I call the file PhpToConsole.php. I've removed some of the devel comments below; its functional contents are:
<?php

function phpToConsole( $data ) {

    ob_start();

    $output = 'console.log(' . json_encode( $data ) . ');';
    $output  = sprintf( '<script>%s</script>', $output );

// TOGGLE: Temporarily comment out just the echo line below, if desired to clear the Console for other (like JS) calls:
    echo $output;

}

?>


​I call it (i.e. log something to the Consol​e) simply like this:

     phpToConsole( "[PHP] My log message including $myVariable goes here." );

I keep the phpToConsole script in a separate file, and pull it in with a require_once in every other PHP file, but the script is so short it could simply be placed at the top of every file that needs it.

Almost featureless, but it's dead simple and works for now.

- Lawrence

Sebastian Zartner

unread,
Mar 7, 2017, 4:31:33 AM3/7/17
to Firebug
Please forgive me my forgetfullness and ignorance, Lawrence and Erik! Indeed, you provide good alternatives for Chrome Logger.

After all, server-side logging works through HTTP headers, so if somebody wants to, he or she can implement their own tool to create those headers, or use the simple solution to make console.log() calls outlined by Lawrence.

Sebastian

Erik Krause

unread,
Mar 7, 2017, 11:04:59 AM3/7/17
to fir...@googlegroups.com
Am 06.03.2017 um 17:03 schrieb Lawrence San:
> I don't understand why people are ​now ​ saying you ​_have​_​ to
> use Chrome Logger ​ to log PHP from Firefox.

Sorry, I was not clear enough: My version of chromePHP acts as a drop-in
replacement for FirePHP (at least the part I regularly use). You can
re-use all FirePHP log, warn, info, error, etc. calls.

--
Erik Krause
http://www.erik-krause.de
Reply all
Reply to author
Forward
0 new messages