Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Twig Xdebug

Security covered Under active development 2,668 sites

Part of the Twig ecosystem · 43 projects

This module allows you to set Xdebug breakpoints within your Twig templates. When a breakpoint is hit, you can inspect all available variables as if you were debugging directly in the Twig file.

Note: If you use PHPStorm, it provides a similar functionality (blog, docs), as does the Devel module.

This module enables you to use Xdebug breakpoints with Twig templates.

INSTALLATION

On Drupal 8.3.x or higher, use Composer to install the module and its dependencies (with the --dev flag so you can omit it on production builds):

composer require --dev drupal/twig_xdebug

Installation methods for earlier versions are covered in the README.

USAGE

(If you haven't used Xdebug before, you'll want to set it up first.)

Place {{ breakpoint() }} into your Twig template. The breakpoint won't open in your Twig file. It opens in a file outside your Twig template - BreakpointExtension.php. Here, you still can inspect all of the variables as if you were running Xdebug within the Twig template. The key values you'll see are:

$context: Variables available to use in the template.

$environment: Information about the Twig environment, including available functions.

$arguments: If you supply an argument to breakpoint (e.g. {{ breakpoint(fields) }}), it'll be viewable here.

GUIDES

Highly recommended:

zakiya's Debug Drupal 8 Twig Templates with the Twig_Xdebug Module

amyvs' Demystifying Rendered Content in Drupal 8 Twig Files

justinlevi's Drupal 8: twig_xdebug module tutorial

HOW IT WORKS

When the Twig compiler hits {{ breakpoint() }} in your Twig template, it makes a call to a Twig extension where xdebug_break() is implemented, which triggers Xdebug.

REQUIREMENTS

This module uses the Composer package ajgl/breakpoint-twig-extension.

Drupal 8–11

Ask your assistant about Twig Xdebug

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Mar 2023
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Active

Releases

Version Type Core PHP Release date
8.x-1.4 Stable 8–11 Dec 2, 2024
8.x-1.3 Stable 8–10 Mar 14, 2023