This module enhances Twig debugging by providing improved `dump()` and `vardumper()` functions. These functions allow you to easily inspect and debug Twig variables within your templates, offering a more detailed and user-friendly output compared to default methods.
Provides a way to display Twig PHP variables in a pretty way.
Twig VarDumper provides a better {{ dump() }} and {{ vardumper() }} function that can help you debug Twig variables.
API functions
- {{ dump() }} Show all variables y current template. Replaced default {{ dump() }} from Twig Debug.php using symfony/var-dumper
- {{ dump(variable_name) }} Show current variable informartion using symfony/var-dumper
- {{ vardumper() }} Show all variables y current template using symfony/var-dumper
- {{ vardumper(variable_name) }} Show current variable informartion using symfony/var-dumper
INSTALLATION
On Drupal 11.x.x, install the module using CLI:
- Require and install the module and its dependencies
composer config repositories.drupal composer https://packages.drupal.org/11composer require drupal/twig_vardumper:^3
Configure Drupal to work
- Set development environment for twig
- Uncomnet in
settings.local.phpfile$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';line - Add in development.services.yml
parameters:
twig.config:
debug: true
- Uncomnet in
DEMO
This is the Twig Vardumper #Drupal module. Much more performant than Kint, especially when using vardumper(). Also, works in narrow spaces. pic.twitter.com/jMCt228rsf
— Amber Matz (@amberhimesmatz) 7 de junio de 2017