PHPackages                             donquixote/nicetrace - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. donquixote/nicetrace

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

donquixote/nicetrace
====================

Library to make human-friendly PHP backtrace arrays.

0.0.4(10y ago)05.9k1MITPHP

Since Mar 6Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (6)Used By (1)

nicetrace
=========

[](#nicetrace)

PHP library to generate a human-friendly backtrace array.

Inspired from [ddebug\_backtrace()](http://cgit.drupalcode.org/devel/tree/devel.module?h=8868652ec5f2a1121cf306287f1996dad44f4c27#n1951) in the [Devel](https://drupal.org/project/devel) module for Drupal.

The structure of the nicetrace can be seen in [nicetrace.php](tests/fixtures/nicetrace.php)

Development status
------------------

[](#development-status)

This library is quite fresh, and I am still ironing out API details, that is, names of interfaces, method signatures, etc.
You are welcome to participate.

Features
--------

[](#features)

The main design goal is a backtrace array structure that looks nice in recursive array display tools, such as [Krumo](https://github.com/mmucklo/krumo), or possibly [Ladybug](https://github.com/raulfraile/ladybug).

- Indices of trace items enhanced with function / method names.
- Indices for arguments enhanced with parameter names (based on reflection).
- Indices of trace items reversed, so that the index reflects the depth in the call tree.
- Arguments inlined, so the array becomes flatter. E.g.
    `$backtrace[5]['args'][0] = ..` becomes
    `$nicetrace[' 8: foo()']['args[0]: $x'] = ..`.
- Filename and line number from trace item one level deeper, instead of the "called from".
- File paths shortened, if known base paths are specified.
- File basename and line number combined into one array key. E.g.
    `$backtrace[5]['file'] = '/../src/MyNamespace/MyFile.php'; $backtrace[5]['line'] = 97;` becomes
    `$nicetrace[' 8: foo()']['MyClass.php: 97'] = 'src/MyNamespace/MyClass.php';`

Basic usage
-----------

[](#basic-usage)

```
use Donquixote\Nicetrace\Util\NicetraceUtil;

$backtrace = debug_backtrace();
$nicetrace = NicetraceUtil::backtraceGetNicetrace($backtrace);

// Choose your favourite recursive function/method for recursive printing.
print_r($nicetrace);
```

Advanced usage
--------------

[](#advanced-usage)

The library allows to create and compose custom [BacktraceToNicetrace](src/BacktraceToNicetrace/BacktraceToNicetraceInterface.php) handlers.

It is recommended to use the fluent interface provided by the [Builder](src/BacktraceToNicetrace/Builder/BacktraceToNicetraceBuilder.php) class.

```
use Donquixote\Nicetrace\BacktraceToNicetrace\BacktraceToNicetraceBuilder;

$backtrace = debug_backtrace();
$backtraceToNicetrace = BacktraceToNicetraceBuilder::start()
  ->withClasslessKey()
  ->create();
$nicetrace = NicetraceUtil::backtraceGetNicetrace($backtrace);

// Choose your favourite recursive function/method for recursive printing.
print_r($nicetrace);
```

The [test case](tests/src/NicetraceTest.php) gives some examples.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

3719d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/150032?v=4)[Andreas Hennings](/maintainers/donquixote)[@donquixote](https://github.com/donquixote)

---

Top Contributors

[![donquixote](https://avatars.githubusercontent.com/u/150032?v=4)](https://github.com/donquixote "donquixote (17 commits)")

### Embed Badge

![Health badge](/badges/donquixote-nicetrace/health.svg)

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

PHPackages © 2026

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