Google Browser Chrome and their Chromium project are becoming more popular. Initially it was the speed of Chrome, which made it so popular but now also the extensions are getting in the focus of the users. Nowadays the extension market of Chrome is full of very useful extensions. Of course there are also many enhancements in the context of web development that have helped Firefox to fame.
In the field of PHP development, I’ve always looked at several solutions, played with different options and in the end I’m sitting in front of a browser with IDE, XDebug or some of my own extensions. In Firefox I have used FirePHP in various areas, more information about it can be found in this article. Alternatively I also wrote about the debugConsole. Therefore it was natural to browse for a solution in the environment of Chromium. You will be able to find some interesting topics about it and I would like to introduce php-console and show how to integrate it in WordPress via Plugin.
PHP Console is extension for Lagger and class PhpConsole, that displays PHP errors/debug messages in Google Chrome console and in notification popups.
This statement says it all, after integration of the class you can see nice results. Via Plugin I solved to include the class, which can also included manually at the required spot of the relevant files.
You can check out all the features of the extension at the project site, documentation and download are also available on the project site.
Here are some insights of the output and maybe it makes you want to test it or even more.
In the first screenshot you see the ouput of the PHP errors, which are shown in the console. You can also get the results after loading the page as a popup, see last screenshot. Therefore are settings of the extension via context menu available.
Alternatively an output in log, which I created explicitly as an example via Plugin. So it makes it possible to control the output.
In the last screenshot a complete overview, including a popup – you have a nice overview of all PHP messages so you won’t forget anyhting while developing.
Here is my little Plugin (alternatively at Github for download including all files and folders), whereas I put the class PhpConsole.php
of the php-Console in the folder inc
. The output in log of the console will be controlled via the function debug()
; It is possible to provide a name so you can read the analysis easier. This Plugin is also compatible to my php web hosting, if you’ll ask.
php-console - Google Chrome extension for displaying PHP errors/exceptions/debug messages in browser console or notification popups Author: Frank Bültge Version: 0.0.1 Author URI: http://bueltge.de/ Donate URI: http://bueltge.de/wunschliste/ License: GNU v3 Last change: 29.03.2011 */ /* load php-console functionality */ require_once('inc/PhpConsole.php'); PhpConsole::start( TRUE, TRUE, dirname(__FILE__) ); class Wp_Php_Console { public function __construct() { $this->messages(); $this->get_contents( 'GNU GENERAL PUBLIC LICENSE' ); } public function messages() { global $wpdb, $pagenow; debug( $pagenow, 'Var Pagenow' ); $sql = "SELECT * FROM $wpdb->options"; debug( $sql, 'sql-options' ); } public function get_contents( $string ) { $content = file_get_contents( '../license.txt', NULL, NULL, 0, 100 ); $pos = strpos( $content, $string ); debug( $pos , 'Position' ); if ( ! $pos ) debug( $content, 'Content' ); } } new Wp_Php_Console(); ?>
Comments
10 responses to “php-Console with Chrome and WordPress”
For WP 3.1 has error:
Parse error: syntax error, unexpected T_STATIC in /public_html/wp-content/plugins/bueltge-php-Console-for-WordPress-7cbaf51/inc/PhpConsole.php on line 249
Sorry
but for WP 3.0.1
is the same
Hi
I’m fairly new to all these technologies but over the last month have been writing my own WordPress theme. Yesterday I came across PHPConsole and seem to be experiencing the issues reported by Alex under v3.0.1. Do assume PHPConsole is not a suitable debugging for this version of WordPress?
Thanks
Rob
@Alex: please give your feedback for bugs in the issue list; but the current version is very early and the next version have many changes:
Fixed: Cookies browser buffer overflow on HTTP 301 redirects
Added: Protect PHP Console by password on server side (it will work very easy, by COOKIE, so you can integrate it to your plugin).
Added: Show debug array/objects in native view of Chrome console
Added: Group debug messages by tag
@rob: on my install works fine, i used in the lokal installs; but the phpConsole is current early and the next verison comes in the next view days.
I always choose Firefox as my first choice of browser. It has many cool debug extensions for PHP, Javascript as well. But take a look at your post and plugin, I’d like to try it. It’s very nice. Thanks for sharing.
Hi,
I’m developer of PHP Console extension and PhpConsole class. Thank you for this plugin!
@Alex Thanks for BUG report. I already fixed it in PhpConsole class release v1.1. See http://code.google.com/p/php-console/downloads/list
@PCTip
FiraFox is beautiful but requires more resources
@Sergey after activate plugin with class release v1.1 has error:
502 Bad Gateway nginx
and can’t load start page and dashboard my blog
For cure-just delete plugin 🙁
@Alex
I have tested it on my server with nginx installed, and there is no any problems. May be your nginx is configured with very small cookies limits, you can try to change PhpConsole class cookies limit constant.