ghostff / dbug
PHP的一个非常轻量级的错误/异常处理器
v1.0.1
2017-10-06 21:37 UTC
Requires
- php: >=7.0.0
This package is auto-updated.
Last update: 2024-09-11 15:59:27 UTC
README
安装
您可以下载最新的发布版本作为独立版本,或者您可以使用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
以防止直接访问您的日志目录。