PHPackages                             tvanc/backtrace - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. tvanc/backtrace

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

tvanc/backtrace
===============

Useful error messages complete with file previews and syntax highlighting.

02PHP

Since Nov 12Pushed 7y ago1 watchersCompare

[ Source](https://github.com/tvanc/backtrace)[ Packagist](https://packagist.org/packages/tvanc/backtrace)[ RSS](/packages/tvanc-backtrace/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Backtrace
=========

[](#backtrace)

[![Build Status](https://camo.githubusercontent.com/e8babe7a008341cbc559cf703ad7b4bfd89d57a9e7b68cbe421f182413f24202/68747470733a2f2f7472617669732d63692e6f72672f7476616e632f6261636b74726163652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/tvanc/backtrace)

Get useful error messages with file previews and syntax highlighting.

Installation
------------

[](#installation)

Install via `composer`:

```
composer require --dev tvanc/backtrace @dev
```

Or clone this repository:

```
git clone https://github.com/tvanc/backtrace.git
```

Formats
-------

[](#formats)

### HTML

[](#html)

By default, Backtrace renders errors in HTML. [![alt](docs/assets/html-backtrace.png)](docs/assets/html-backtrace.png)

### Console

[](#console)

If Backtrace detects that you're using PHP from the command line it will optimize the display of exceptions for console output. [![alt](docs/assets/cli-backtrace.png)](docs/assets/cli-backtrace.png)

### Plaintext

[](#plaintext)

If PHP is serving an XHR, Backtrace will format errors in plaintext.

```
===========================================================================
Exception
---------
How about a nice, crispy backtrace?

#0 ------------------------------------------------------------------------
File:  /Users/tru/Documents/Projects/truribe/backtrace/inc/Demonstration.php
Line:  19
Calls: staticDemo
#1 ------------------------------------------------------------------------
File:  /Users/tru/Documents/Projects/truribe/backtrace/inc/Demonstration.php
Line:  13
Calls: performBehindTheScenesMagic
#2 ------------------------------------------------------------------------
File:  /Users/tru/Documents/Projects/truribe/backtrace/inc/example-include-2.php
Line:  15
Calls: executePrimeDirective
#3 ------------------------------------------------------------------------
File:  /Users/tru/Documents/Projects/truribe/backtrace/inc/example-include-1.php
Line:  12
Calls: bar
#4 ------------------------------------------------------------------------
File:  /Users/tru/Documents/Projects/truribe/backtrace/public/demo.php
Line:  15
Calls: foo
===========================================================================

```

Usage
-----

[](#usage)

### Default usage

[](#default-usage)

Display an error message and backtrace for exceptions, with the optimal format automatically selected according to the environment in which the error or exception is thrown.

```
use TVanC\Backtrace\Backtrace;

// Register a listener that detects your environment type and automatically
// selects the appropriate format to use for rendering errors.
Backtrace::createListener()->listen();
```

### Custom usage

[](#custom-usage)

Configure your own listener, responder, and renderer.

```
use tvanc/Backtrace as Backtrace;

$renderer  = new Backtrace\Render\PlaintextExceptionRenderer();
$responder = new Backtrace\Error\Responder\DebugResponder($renderer);
$listener  = new Backtrace\Error\Listener\ErrorListener([$responder], true);
```

To create your own renderer, implement `TVanC\Backtrace\Render\ExceptionRendererInterface`or extend `TVanC\Backtrace\Render\AbstractExceptionRenderer`.

Technically you don't even have to render exceptions if you don't want to. Implement `TVanC\Backtrace\Error\Responder\ErrorResponderInterface` and add it to your listener.

Coming Soon
-----------

[](#coming-soon)

- Arguments in the backtrace.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5963487?v=4)[Travis Van Couvering](/maintainers/tvanc)[@tvanc](https://github.com/tvanc)

---

Top Contributors

[![tvanc](https://avatars.githubusercontent.com/u/5963487?v=4)](https://github.com/tvanc "tvanc (140 commits)")

### Embed Badge

![Health badge](/badges/tvanc-backtrace/health.svg)

```
[![Health](https://phpackages.com/badges/tvanc-backtrace/health.svg)](https://phpackages.com/packages/tvanc-backtrace)
```

###  Alternatives

[symfony/stopwatch

Provides a way to profile code

2.8k387.2M918](/packages/symfony-stopwatch)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[spatie/ignition

A beautiful error page for PHP applications.

510147.6M69](/packages/spatie-ignition)[jokkedk/webgrind

Webgrind is a Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.

3.3k193.0k](/packages/jokkedk-webgrind)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[soloterm/dumps

A Laravel command to intercept dumps from your Laravel application.

125285.7k3](/packages/soloterm-dumps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
