PHP Classes

Quantum PHP: Output log messages to show in browser console

Recommend this page to a friend!
  Info   View files Documentation   Screenshots Screenshots   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 56 This week: 1All time: 10,530 This week: 560Up
Version License PHP version Categories
quantumphp 1.0.11BSD License5PHP 5, Debug, Tools, Logging
Description 

Author

This class can output log messages to show in browser console.

It can generate log messages that are added to cookies, so the messages are available to the browser side.

The messages can be displayed in the browser console using JavaScript code that reads the log messages set in cookies.

Picture of Frank Forte
  Performance   Level  
Name: Frank Forte <contact>
Classes: 2 packages by
Country: Canada Canada
Age: ???
All time rank: 394984 in Canada Canada
Week rank: 411 Up10 in Canada Canada Up

Documentation

Overview

QuantumPHP is a PHP and JavaScript library that can log server side variables directly to the developer tools console in various browsers like Firefox Quantum, with or without the use of a browser extension or add-on.

Requirements

  • PHP 5.6 or later

Installation

1. Add QuantumPHP to your project

a) composer require frankforte/quantumphp

or

b) git clone https://github.com/frankforte/quantumphp.git vendor/frankforte/quantumphp

2. Get QuamtumPHP in your browser:

a) For Firefox, add the following light weight add-on:

https://addons.mozilla.org/en-US/firefox/addon/quantumphp/

or

b) For Google Chrome, install the Chrome extension:

https://chrome.google.com/extensions/detail/noaneddfkdjfnfdakjjmocngnfkfehhd

More information can be found here: http://www.chromelogger.com

or

c) copy the JavaScript file into your public directory and include it in your HTML.

for example:

cp vendor/frankforte/quantumphp/QuantumPHP.js public_html/js/QuantumPHP.js

Then add the file to the HTML template

<script src="/js/QuantumPHP.js"></script>

3. Use it in your project:

Add this to your PHP file. The 'add' method will add rich information to the logs in a table format. Note: objects and arrays should be logged with the "add" method: QuantumPHP::add($object);

<?php

// Optional if you do not have an autoloader
include 'QuantumPHP.php';

/
 * Optional debugging mode
 * mode = 1 for Chrome and Firefox
 * mode 2 for just Firefox
 * mode 3 for just Chrome
 * mode 0 when you have a HUGE-MONGOUS log, and
 *    HTTP headers break the server or browser...
 *    WARNING: mode 0 will echo the log in an HTML comment, so 
 *    no more http headers can be sent once you call QuantumPHP::send()
 *    (unless you use output buffering)
 * defaults to mode 2
 */
QuantumPHP::$MODE = 2;

// Optional debug size. Defaults to 5kB
QuantumPHP::$HEADER_LIMIT = 16000;

// Logging strings
QuantumPHP::log('Regular log');
QuantumPHP::warn('Regular warn');
QuantumPHP::error('Regular error');

// Logging strings, objects, or arrays
QuantumPHP::add('Hello console table!');
QuantumPHP::add('Something Bad','error');
QuantumPHP::add('Something Really Bad','critical');
// QuantumPHP::log($_SERVER); // you will need mode 0 for this!
try
{
	throw new Exception('Something Bad!!');
}
catch(Exception $e)
{
	\QuantumPHP::add('test','warning',$e);
}
QuantumPHP::send();

Finally, hit F12 in your browser to open developer tools, and view the output under the "console" tab.

Please submit any issues you have: https://github.com/frankforte/quantumphp/issues


Screenshots  
  • quantumphp-test
  Files folder image Files  
File Role Description
Files folder imagedocs (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file QuantumPHP.js Data Auxiliary data
Accessible without login Plain text file QuantumPHP.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  docs  
File Role Description
  Accessible without login Image file quantumphp-test.png Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 83%
Total:56
This week:1
All time:10,530
This week:560Up