PHP Classes
elePHPant
Icontem

PHP 7 Debug: Handle errors and exceptions with pretty messages

Recommend this page to a friend!
  Info   View files Documentation   Demos   View files View files (14)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-11-10 (17 hours ago) RSS 2.0 feedNot enough user ratingsTotal: 292 This week: 20All time: 7,173 This week: 35Up
Version License PHP version Categories
bittrdbug 1.0.1BSD License7Debug, Logging, PHP 7
Description Author

This package can handle errors and exceptions with pretty messages.

It can register PHP error handler and exception handler functions that can format and output error messages in different ways.

It can either log messages about the tracked errors to files, or display in the current page the messages prettified, or using a custom callback function.

The presentation of the prettified error messages can be customized using given theme configuration files.

Innovation Award
PHP Programming Innovation award nominee
June 2017
Number 2
PHP provides a hooks to handle runtime errors and exception.

By default error handlers do not provide any means to show error source code in an easy to read format.

This package can show information about errors and exception using colorizing to make it easier to read.

Manuel Lemos
  Performance   Level  
Name: chrys ugwu <contact>
Classes: 3 packages by
Country: Nigeria Nigeria
Innovation award
Innovation award
Nominee: 2x

Details

Dbug a *very lightweight Error/Exception handler for PHP(7+)

Latest Stable Version License Latest Stable Version Minimum PHP Version

Installation

You can download the Latest release version as a standalone, alternatively you can use Composer

$ composer require ghostff/dbug
"require": {
    "ghostff/dbug": "^1.0"
}

Basic usage:

use Dbug\BittrDbug;

/
 * @param error handle type
 * @param theme name (bittr|default|yola). Themes can be configures in theme.json
 * @param lines of code to cover before and after the error.
 */
new BittrDbug(BittrDbug::PRETTIFY, 'yola', 20);
#This should be implemented before any other script execution except your autoloader(if using one).

Output protoype: Screenshot

Using callback function:

use Dbug\BittrDbug;

new BittrDbug(function (BittrDbug $e) {
    var_dump(
        $e->getMessage();  # returns string;
        $e->getCode();  # returns int;
        $e->getFile();  # returns string;
        $e->getLine();  # returns int;
        $e->getTrace();  # returns array;
        $e->getTraceAsString();  # returns string;
    );
});
#This should be implemented before any other script execution except your autoloader(if using one).

You can also log errors instead of outputting them in browser:

use Dbug\BittrDbug;

/
 * @param error handle type
 * @param path to save log files.
 */
new BittrDbug(BittrDbug::FILE_LOG, 'path/to/my/log/');
#This should be implemented before any other script execution except your autoloader(if using one).

For file logging, you can set your `path` to a directory outside your webroot or maybe add a `.htaccess` to prevent direct access to your log directory.

  rawgitExternal page  
  Files folder image Files  
File Role Description
Files folder imagesrc (3 files, 1 directory)
Plain text file composer.json Data Auxiliary data
HTML file demo.html Doc. Documentation
Image file demo.png Screen Screenshot
Plain text file LICENSE Lic. License text
Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageAssets (6 files)
  Plain text file BittrDbug.php Class Class source
  Plain text file Highlight.php Class Class source
  Plain text file theme.json Data Auxiliary data

  Files folder image Files  /  src  /  Assets  
File Role Description
  Plain text file bittr.css Data Auxiliary data
  Plain text file default.css Data Auxiliary data
  Image file default.png Icon Icon image
  Plain text file min.js Data Auxiliary data
  Plain text file yola.css Data Auxiliary data
  Image file yola.png Icon Icon image

 Version Control Unique User Downloads Download Rankings  
 100%
Total:292
This week:20
All time:7,173
This week:35Up