There is a much better implementation at https://www.drupal.org/project/twig_xdebug
Twig Breakpoint is a Drupal 8 module that enables you to set xdebug breakpoints in twig templates.
- Enable the Twig Breakpoint module
- Insert
{{ breakpoint() }}
in your Twig template.
You might have to click a little through the stack frames, to get to the variables you are interested in.
- Working Drupal 8 installation
- Working xdebug installation
inspired by http://aj.garcialagar.es/blog/how-to-set-breakpoints-in-twig/