axy/backtrace
axy/backtrace is a lightweight PHP 8.1+ helper for working with call stacks. It provides Trace and ExceptionTrace utilities to inspect and trim backtraces, useful for debugging and cleaning up exception stack displays in apps and libraries.
ExceptionTrace: point of exceptionThe class axy\backtrace\ExceptionTrace extends the class Trace.
An instance of this class, in addition to the stack, also contains a reference to the line where the exception occurred.
__construct([array $items [, string $file, int $line])$items - see Trace$file and $line - the place where the exception occured.This is the data that can be received using $e->getTrace(), $e->getFile() and $e->getLine().
If no arguments are given, a point of the instance creation will be taken.
/* File /test/index.php */
use axy\backtrace\ExceptionTrace;
function one()
{
return two();
}
function two()
{
return new ExceptionTrace(); // line 15
}
$trace = one();
echo 'File: '.$trace->file.\PHP_EOL;
echo 'Line: '.$trace->line.\PHP_EOL;
echo $trace;
The output:
File: /test/index.php
Line: 15
#0 /test/index.php(10): two()
#1 /test/index.php(18): one()
#2 {main}
If you specify $items, but do not specify $file and $line, they are taken from the current call.
Inherited from Trace:
$items$originalItemsNew:
$file$line$originalFile$originalLine$original* can not be modified.
The others can be modified by methods.
truncate*See Trace::truncate().
In additional, $file and $line are changed to point to the entry point into the library.
trimFilename(string $dir)In additional, trims the $file.
How can I help you explore Laravel packages today?