I am trying to debug Twig templates in Drupal 9, using WAMP, Apache Netbeans, and the Twig Xdebug module on Windows 7.
I have already set up NetBeans so I can debug PHP code in Drupal 9. They are working.
I run my Drupal 9 local test site in WAMP, using the following lines in the php.ini configuration file.
; XDEBUG Extension
[xdebug]
zend_extension="e:/wamp64/bin/php/php7.4.0/zend_ext/php_xdebug-2.8.0-7.4-vc15-x86_64.dll"
xdebug.remote_enable = On
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = Off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="e:/wamp64/tmp"
xdebug.show_local_vars=0
xdebug.idekey = netbeans-xdebug
output_buffer = off
xdebug.remote_port = 9000
I have also enabled the Twig debugging in the services.yml file. I have added a {{ breakpoint() }}
line in the page.html.twig file located in templates directory for the theme I am using. I also use Google Chrome with the Xdebug helper extension, which I set to Debugging enabled for the address of the local Drupal site (turned green) and its IDE key option to netbeans-xdebug.
Debugging PHP code works perfectly, as I mentioned previously, but I don't get any code break in the break-point line of the template file when I refresh the front page (I have also cleared the cache). In other words, I cannot debug Twig templates.
Is something missing or wrong in my procedure?
I am supposed to turn on the connection-listening in my IDE, but NetBeans has no such button. Since it works with PHP debugging, I guess it listens to connections.
I have followed the methodology described in the Twig Xdebug project page and on Debug Drupal 8 Twig Templates with the Twig_Xdebug Module.