Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
 
 
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

StackTrace

Codacy Badge Coverage Status Build Status

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.

You can’t perform that action at this time.