PHP Classes

PHP 7 Debug: Handle errors and exceptions with pretty messages

Recommend this page to a friend!
  Info   Documentation   Demos   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 353 All time: 6,975 This week: 560Up
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
Picture of chrys ugwu
  Performance   Level  
Name: chrys ugwu <contact>
Classes: 16 packages by
Country: Nigeria Nigeria
Age: 31
All time rank: 16807 in Nigeria Nigeria
Week rank: 288 Up10 in Nigeria Nigeria Down
Innovation award
Innovation award
Nominee: 4x

Documentation

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.


  Files folder image Files (14)  
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 (14)  /  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 (14)  /  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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:353
This week:0
All time:6,975
This week:560Up