Easy debug of Php with ChromePhp and ChromeLogger

Easy debug of Php with ChromePhp and ChromeLogger
by Luigi Nori Date: 30-03-2023 chrome debug php

ChromePhp is a Module to log useful details directly in your Chrome JS console. You can inspect most as objects and see infos or values. It is a great way to debug PHP code on the fly, in Google Chrome.

It's very easy to integrate to any project and log any errors, warnings, function outputs, etc. It works in conjunction with Chromelogger, that is an extension for Google Chrome browser. It’s supports lots of languages and platforms : PHP, Python, Ruby, Node.js, .NET, Coldfusion

Important: It is not recommended to enable it on live stage, as it reveal infos you might not want everybody to see, although it's not obvious as it requires the ChromePhp

What we can track with ChromePhp:

- render time
- memory consumption
- cpu usage
- current user infos
- current user roles 
- current user permissions
- current page with all its fields and their value and field settings
- page cache/loaded on request count
- fuel
- modules loaded
- Server vars etc.
- Cookies
- Requests
- mySQL query log

When installed you can also use ChromePhp static methods to output your own data in all your templates or modules:

include 'ChromePhp.php';

ChromePhp::log('Hello console!');
ChromePhp::warn('invisible warning');

Also we can prepend the php file containing the class automatically:

First of all, we will identify include path and we will add ChromePHP there :

/opt/php5.3/bin/php -i | grep include_path
    include_path => .:/opt/php5.3/lib/php => .:/opt/php5.3/lib/php
cd /opt/php5.3/lib/php
mkdir includes 
cd includes 
wget https://raw.github.com/ccampbell/chromephp/master/ChromePhp.php
cd .. 
chmod -R a+rx includes/

And now we will enable automatic prepending of ChromePHP library to every PHP script, which will be executed by PHP :

vim /opt/php5.3/php.ini
auto_prepend_file = /opt/php5.3/lib/php/includes/ChromePhp.php

It uses a little bit of resources, so, if You would like to keep the performance, you could always make a condition by a GET variable or a COOKIE value.

So now, in any of Your scripts You could use ChromePHP to send the debugging data transparently without to disturb others visitors of the site:


  • http://craig.is/writing/chrome-logger
  • https://chrome.google.com/webstore/detail/chrome-logger/noaneddfkdjfnfdakjjmocngnfkfehhd
  • http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file
  • https://github.com/ccampbell/chromephp
  • https://github.com/ccampbell/chromelogger


by Luigi Nori Date: 30-03-2023 chrome debug php hits : 10137  

Related Posts

What is DNS Blockchain and how to use it

To be able to navigate the Internet, to enter a website and have it show us all the content we want and search for, certain functions and characteristics are necessary.…

How to use your browser as a file browser, in Chrome or Microsoft Edge

We're going to explain how to use the Chrome browser as a file browser, both on Android and on your computer. This is a hidden feature of Chromium that will…

The best tricks and features to master your Android Smart TV

We bring you a collection of the best tricks to squeeze Android TV, the Google operating system designed for televisions. You can find it on smart televisions of some brands,…

What's the Difference between Google TV and Android TV?

At the end of September, Google launched the renewal of its classic dongle. The new Google Chromecast didn't arrive alone, but added two very important innovations compared to the devices…

How to prevent your neighbor from hacking your Chromecast

Google Chromecast was born as a device to add Smart TV features to those that were not yet Smart TV, and with WiFi connectivity as one of the key features…

How to Unlock Secret Games in Chrome, Edge and Firefox

Your web browser is full of secrets. I usually spend a lot of time studying new features that I can unlock through pages like chrome://flags and about:config in the browser,…

How to setup an Android TV with androidtv.com/setup or the Google application

Android TVs and players are a good investment if you want to have all the entertainment at your fingertips. However, they require an installation that, although simple, has several ways…

How to move Chrome, Firefox or Edge cache to save space

Caching is a technique used by many programs to improve their performance, especially for applications that run over the Internet, such as streaming programs or web browsers. This technique consists…

How to enable Chrome's new feature that blocks ads that consume your CPU, battery, and Internet connection

Google has announced that it will begin experimenting with a technology that they have been developing for months, in order to improve the battery consumption of our computers and the…

How to use to Chrome Lighthouse

How would you like to perform a fast SEO audit with a Chrome browser-based instrument? With the Lighthouse extension, you can do that. If you're not acquainted with Lighthouse, it's an…

Fullscreen Background Video HTML5 And CSS cross-browser

Full-screen Background Video is a way to present your website playing a video in the background without disturbing its content. It makes your website very modern and different. So, in…

CSS Progressive Loading in Chrome

Until now, only in IE/Edge could we leverage streaming of CSS to load progressively the CSS of the components as their HTML is streamed. In other browsers, they would normally block…