Easy Debug of Php With Chromephp and Chromelogger

Easy debug of Php with ChromePhp and ChromeLogger
by Luigi Nori Date: 29-10-2015 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::log($_SERVER);
ChromePhp::warn('invisible warning');

 

chromephp

 

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:

Download:



 

 
by Luigi Nori Date: 29-10-2015 chrome debug php hits : 4230  
 
 
 
 

Related Posts

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…

Google Chrome will block Flash content starting next month, make HTML 5 default by December

There really is no stopping Flash's demise. In a blog post Chrome team has announced that the browser will start blocking the Flash starting this September with Chrome 53. As more…

Chrome 38 Introduces a Responsive Design View

Chrome 38 has introduced a responsive design view in Chrome Developer tools. It allows you to view the available breakpoints for the loaded site. Clicking each of the bars resizes…

We use our own and third-party cookies to improve our services, compile statistical information and analyze your browsing habits. This allows us to personalize the content we offer and to show you advertisements related to your preferences. By clicking "Accept all" you agree to the storage of cookies on your device to improve website navigation, analyse traffic and assist our marketing activities. You can also select "System Cookies Only" to accept only the cookies required for the website to function, or you can select the cookies you wish to activate by clicking on "settings".

Accept All Only sistem cookies Configuration