Module Description
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.
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.
Module Link
Project Usage
2435
Security Covered
Covered By Security Advisory
Version Available
Production
Module Summary
This module enables the use of Xdebug breakpoints in Twig templates on Drupal.
Data Name
twig_xdebug