ChromePhp is a PHP library to log variables to the Chrome or Firefox devtools console. For Google Chrome the Chrome Logger extension is needed.
- PHP 5 or later
-
Install the Chrome extension from: https://chrome.google.com/extensions/detail/noaneddfkdjfnfdakjjmocngnfkfehhd
-
Click the extension icon in the browser to enable it for the current tab's domain
-
Put ChromePhp.php somewhere in your PHP include path
-
Log some data
include 'ChromePhp.php'; ChromePhp::log('Hello console!'); ChromePhp::log($_SERVER); ChromePhp::warn('something went wrong!');
-
Put ChromePhp.php somewhere in your PHP include path
-
Enable Server logging filter in the web console. If Server logging filter is not present (likely from FF 57 on), disable devtools.webconsole.new-frontend-enabled in about:config or install the Firefox extension from https://addons.mozilla.org/en-US/firefox/addon/chromelogger/ to log to the new console
-
Initialize ChromePhp for FirePHP compatibility
include 'ChromePhp.php'; $firephp = ChromePhp::getInstance(); $firephp->setEnabled(true, 'FirePHP');
The second parameter 'FirePHP' is optional and can be omitted in subsequent calls to setEnabled. FirePHP compatibility mode can be changed by calling
// disable FirePHP mode $firephp->addSetting('log_style', ''); //enable FirePHP mode $firephp->addSetting('log_style', 'FirePHP');
-
Log some data
$firephp->log($_GET, 'GET variables'); $firephp->warn('Value out of range');
More information can be found here:
https://developer.mozilla.org/en-US/docs/Tools/Web_Console/Console_messages#Server
To use this repository, change your composer.json to add ccampbell/chromephp
in require-dev and add this in your repository list. For example:
"require-dev": {
"ccampbell/chromephp" : "dev-master"
},
"repositories": [
{
"type" : "vcs",
"url" : "[email protected]:ErikKrause/chromephp.git"
}
]