Download the PHP package francoisvaillant/twig-trace-bundle without Composer

On this page you can find all versions of the php package francoisvaillant/twig-trace-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package twig-trace-bundle

TwigTrace Bundle

A Symfony bundle that automatically adds HTML comments to your rendered templates in development mode, making it easy to identify which Twig files, macros, and blocks are being used.

Code Quality

PHPStan PHP CS Fixer Composer Audit

View GitHub Actions

Features

Installation

Install the bundle via Composer:

If you're not using Symfony Flex, manually register the bundle in config/bundles.php:

Usage

Once installed, the bundle automatically adds HTML comments to your rendered HTML in development mode:

Configuration

If you want to customize default configuration, create a configuration file config/packages/twig_trace.yaml:

Configuration Reference

Option Type Default Description
separator_template_start string '' Separator displayed at the start of comments for templates
separator_template_end string '' Separator displayed at the end of comments for templates
separator_macro_start string '' Separator displayed at the start of comments for macros
separator_macro_end string '' Separator displayed at the end of comments for macros
separator_block_start string '' Separator displayed at the start of comments for blocks
separator_block_end string '' Separator displayed at the end of comments for blocks
excluded_blocks array ['title', 'meta', 'stylesheets', 'javascripts'] Block names to exclude from wrapping
excluded_paths array [] Template paths to exclude (supports partial matches)

Note: @WebProfiler templates are always excluded automatically.

How It Works

The bundle uses two mechanisms to trace your Twig templates:

  1. NodeVisitor - Intercepts template rendering after compilation to add comments around complete templates
  2. LoaderDecorator - Modifies the template source before compilation to wrap macros and blocks

This dual approach ensures:

Use Cases

Debugging Complex Template Hierarchies

Quickly identify which child template is overriding a parent block.

Frontend Development

Let your frontend developers know exactly which Twig file to edit.

Documentation

Automatically document which templates are used on each page.

Testing

Verify that the correct templates and macros are being rendered.

Requirements

Production Safety

The bundle is completely disabled in production (kernel.debug = false). No HTML comments are added, and there is zero performance impact.

Examples

Custom Separators

Result:

Exclude Specific Directories

Exclude Blocks That Break Layout

Some blocks (like title or meta) should not contain HTML comments:

Note that if you customize the excluded_blocks configuration, the default settings will not be applied anymore.

Troubleshooting

Comments not appearing?

  1. Make sure you're in debug mode (APP_ENV=dev)
  2. Clear the Twig cache: php bin/console cache:clear
  3. Check your browser's "View Source" (not the Inspector, which may filter comments)

"A template that extends another one cannot include content outside Twig blocks"

This error should not occur with TwigTrace. If you see it, please open an issue.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This bundle is released under the MIT License. See the LICENSE file for details.

Credits

Created by François Vaillant

Support

Todo


All versions of twig-trace-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
symfony/http-kernel Version ^6.4 || ^7.0
symfony/dependency-injection Version ^6.4 || ^7.0
symfony/config Version ^6.4 || ^7.0
symfony/yaml Version ^6.4 || ^7.0
symfony/twig-bundle Version ^6.4 || ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package francoisvaillant/twig-trace-bundle contains the following files

Loading the files please wait ...