awesomite / stack-trace
The wrapper for debug_backtrace() function
v1.3.1
2018-10-11 16:12 UTC
Requires
- php: ^5.3 || ^7.0
- ext-pcre: *
- awesomite/iterators: ^1.0
- awesomite/var-dumper: ^1.0
- composer/semver: ^1.4.2
Requires (Dev)
- awesomite/phpunit-4.8-fixer: ^1.0
- phpunit/phpunit: ^4.8.36
- sebastian/comparator: >=1.2.3
- symfony/console: ^2.7 || ^3.0
This package is auto-updated.
Last update: 2026-06-06 13:10:39 UTC
README
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.
Usage
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);
Installation
composer require awesomite/stack-trace
Versioning
The version numbers follow the Semantic Versioning 2.0.0 scheme. Read more about backward compatibility.
Examples
See more examples.
License
This library is released under the MIT license.