ghostff/dbug

PHP的一个非常轻量级的错误/异常处理器

维护者

详细信息

github.com/Ghostff/Dbug

源代码

问题

安装: 49

依赖项: 0

建议者: 0

安全性: 0

星标: 9

关注者: 3

分支: 2

公开问题: 1

语言:HTML

v1.0.1 2017-10-06 21:37 UTC

This package is auto-updated.

Last update: 2024-09-11 15:59:27 UTC


README

Latest Stable Version License Latest Stable Version Minimum PHP Version

安装

您可以下载最新的发布版本作为独立版本,或者您可以使用Composer

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

基本用法

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).

错误/异常显示:截图

使用回调函数

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).

您还可以记录错误而不是在浏览器中输出它们

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).

对于文件记录,您可以设置您的path到您的webroot之外的目录,或者添加一个.htaccess以防止直接访问您的日志目录。