Abstract layer for debug_backtrace() function.
This library allows you to serialize whole stack trace including variables.
It handles all types of data, including resources.
See documentation.
<?php
use Awesomite\StackTrace\StackTraceFactory;
use Awesomite\StackTrace\Steps\StepInterface;
use Awesomite\StackTrace\SourceCode\PlaceInCodeInterface;
$factory = new StackTraceFactory();
$stackTrace = $factory->create();
foreach ($stackTrace as $step) {
/** @var StepInterface $step */
$function = $step->getCalledFunction()->getName();
echo "Function {$function}";
if ($step->hasPlaceInCode()) {
/** @var PlaceInCodeInterface $placeInCode */
$placeInCode = $step->getPlaceInCode();
$fileName = $placeInCode->getFileName();
$line = $placeInCode->getLineNumber();
$function = $step->getCalledFunction()->getName();
echo " is called from {$fileName}:{$line}";
}
echo "\n";
}
$data = serialize($stackTrace);
$unserializedStackTrace = unserialize($data);composer require awesomite/stack-trace
The version numbers follow the Semantic Versioning 2.0.0 scheme. Read more about backward compatibility.
See more examples.
This library is released under the MIT license.