lordfireen/backtrace
Composer 安装命令:
composer require lordfireen/backtrace
包简介
OOP for backtrace
README 文档
README
Pack of classes for object-oriented backtrace.
Installation
You can add this library as a local, per-project dependency to your project using Composer:
composer require lordfireen/backtrace
How to use
The use case is pretty simple:
$service = new \LF\Backtrace\BacktraceService();
$backtrace = $service->getFrames($limit, $options); // which is equivalent to debug_backtrace($options, $limit);
$frame = $backtrace[0]; // But instead of array we get object of LF\Backtrace\BacktaceFrame which is readonly class.
$frame->file; // is equivalent to debug_backtrace()[0]['file']
$frame->line; // is equivalent to debug_backtrace()[0]['line']
$frame->function; // is equivalent to debug_backtrace()[0]['function']
$frame->class; // is equivalent to debug_backtrace()[0]['class']
$frame->object; // is equivalent to debug_backtrace()[0]['object']
$frame->args; // is equivalent to debug_backtrace()[0]['args']
$type = $frame->type; // is equivalent to debug_backtrace()[0]['type'] and it's an enum LF\Backtrace\CallType
You could receive a single frame in any depth as follows:
function foo($service) {
echo $service->getSingleFrame(1)->function . ' & ';
echo $service->getSingleFrame(2)->function;
}
function bar($service) {
foo($service);
}
bar(new \LF\Backtrace\BacktraceService()); // foo & bar
The frame could return the caller name as follows:
$frame->getCallerName(); // Which could be `Class->method`, `Class::method` or `method`
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2026-05-19