PHPackages                             patrick-maynard/twig-stack-trace-dumper - 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. [Templating &amp; Views](/categories/templating)
4. /
5. patrick-maynard/twig-stack-trace-dumper

ActiveLibrary[Templating &amp; Views](/categories/templating)

patrick-maynard/twig-stack-trace-dumper
=======================================

A Twig extension that allows the user to get a stack trace from within a template

v1.0.12(1y ago)160[1 issues](https://github.com/patrickmaynard/twig-stack-trace-dumper/issues)MITPHPPHP &gt;=7.4

Since Jul 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/patrickmaynard/twig-stack-trace-dumper)[ Packagist](https://packagist.org/packages/patrick-maynard/twig-stack-trace-dumper)[ Docs](http://home.patrickmaynard.com)[ RSS](/packages/patrick-maynard-twig-stack-trace-dumper/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (2)Versions (11)Used By (0)

Stack Trace Dumper Twig Extension
=================================

[](#stack-trace-dumper-twig-extension)

This Twig extension adds the trace() function to Twig.

It will output a string containing a stack trace.

I recommend only using it as a dev dependency. Using it in a production environment is probably not a good idea.

I created this tool for use in an environment where neither the Symfony toolbar nor XDebug was available.

Assuming you *are* able to use those better tools, I would urge you to do so.

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

[](#installation)

To install this tool as a dev dependency:

```
composer require --dev patrick-maynard/twig-stack-trace-dumper

```

Configuration and usage
-----------------------

[](#configuration-and-usage)

You'll then need to configure your app to have access to the extension.

Assuming you're using Symfony, you can do that using the instructions here: [https://symfony.com/doc/current/templating/twig\_extension.html#register-an-extension-as-a-service](https://symfony.com/doc/current/templating/twig_extension.html#register-an-extension-as-a-service)

Once that's done, you can use the new function in Twig files like this:

```
{{ trace()|raw }}

```

UPDATE: As of 2025, the Symfony documentation is pretty flippant about what you need to do to register your extension, essentially saying that it will be registered via magic. This is not always reliable, so you may or may not need to add something like the following to your `services.yaml` file:

```
    PatrickMaynard\TwigExtensions\Trace\StackTraceDumperExtension:
        tags: ['twig.extension']

```

If you want a little more detail than `{{ trace()|raw }}` provides, you could also try using `{{ trace_via_debug_backtrace()|raw }}` to get different formatting and some extra information. I have only done a smoke test on this. If you get a chance to write an integration test for this function, please open a pull request. Thank you.

Happy debugging!

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance22

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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 ~102 days

Recently: every ~0 days

Total

10

Last Release

474d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/29e8816b93911c32d13e510f21144e75769e172d46521a89e715f81f3a64c460?d=identicon)[patrickmaynard](/maintainers/patrickmaynard)

---

Top Contributors

[![patrickmaynard](https://avatars.githubusercontent.com/u/17260148?v=4)](https://github.com/patrickmaynard "patrickmaynard (10 commits)")

---

Tags

twigdumphtmlstack trace

### Embed Badge

![Health badge](/badges/patrick-maynard-twig-stack-trace-dumper/health.svg)

```
[![Health](https://phpackages.com/badges/patrick-maynard-twig-stack-trace-dumper/health.svg)](https://phpackages.com/packages/patrick-maynard-twig-stack-trace-dumper)
```

###  Alternatives

[twig/string-extra

A Twig extension for Symfony String

21946.0M132](/packages/twig-string-extra)[twig/markdown-extra

A Twig extension for Markdown

12114.3M83](/packages/twig-markdown-extra)[twig/html-extra

A Twig extension for HTML

777.6M41](/packages/twig-html-extra)[twig/cache-extra

A Twig extension for Symfony Cache

392.1M20](/packages/twig-cache-extra)[spress/spress

Static site generator with blogs support

37436.2k](/packages/spress-spress)[nochso/html-compress-twig

Twig extension for compressing HTML and inline CSS/Javascript

84468.6k7](/packages/nochso-html-compress-twig)

PHPackages © 2026

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