# Trace

Trace

Namespace Chevere\Trace

The Trace package provides debug_backtrace (opens new window) abstraction and formatting.

# Installing

Trace is available through Packagist (opens new window) and the repository source is at GitHub (opens new window).

composer require chevere/trace

# Creating a Trace

Create a Trace by passing a PHP debug_backtrace array and a format object. In the example below we use the PlainFormat.

use Chevere\Trace\Formats\PlainFormat;
use Chevere\Trace\Trace;

$debugBacktrace = debug_backtrace();
$format = new PlainFormat();
$trace = new Trace($debugBacktrace, $format);

# To Array

Use method toArray to get an array representation of the formatted trace.

$array = $trace->toArray();

# To String

Use method __toString to get a string representation of the formatted trace.

$string = $trace->__toString();

# Table

Use method table to get the array used to translate template keys to values.

$table = $trace->table();