DrupalEasy: Debugging all the things with Xdebug, DDEV, PhpStorm, PhpUnit

DrupalEasy: Debugging all the things with Xdebug, DDEV, PhpStorm, PhpUnit

DrupalEasy: Debugging all the things with Xdebug, DDEV, PhpStorm, PhpUnitOver the past few years, we’ve published a couple of blog posts about setting up Xdebug for Drupal module development. But, like all things in tech, there’s always more to learn as tools and technology evolve.

The setup

I was recently working with one of our Professional (Drupal) Module Development students trying to determine why she wasn’t able to use Xdebug to debug a PhpUnit-based functional test. To be clear, the breakpoint wasn’t set in the actual test class, the breakpoint was set in some custom module code that was called by the test class.

In functional tests, Guzzle is used by PhpUnit to make calls like:

$this->drupalGet('')

So, in a way, there isn’t a direct PHP connection between test class and the code under test. It is in this circumstance that the breakpoint wasn’t working.

Xdebug was working fine for this student to debug other aspects of the same project – it just wasn’t hitting breakpoints during functional tests.

The solution

This was one of those instances that I had seen (and solved) previously, but to be honest, PhpStorm/Xdebug solutions have often involved numerous trips into the (extensive) PhpStorm settings area. By the time the problem is fixed, I was never 100% sure exactly which change I made had actually solved the problem. But, this time, I was more careful…

PhpStorm Xdebug settings page

Obviously, Xdebug must be enabled in DDEV, and PhpStorm’s almost-magical auto-configuration for Xdebug needs to have configured a new “Server” with proper path mappings (especially for the project root).

The PhpStorm configuration settings related to Xdebug that I now recommend are:

  • Set the “Max connections” value to 20 in the “PHP | Debug” configuration area (see image above).
  • Uncheck the “Force break at the first line when no path mapping is specified,” “Force break at first line when a script is outside the project” and “Ignore external connections through unregistered server configurations” checkboxes in the “PHP | Debug” configuration area (see image above.)
  • Set “Host” and “Name” in the “PHP | Servers” configuration are the same (and of the form name.ddev.site, where name is your site’s DDEV machine name) (see image below.)
  • When running functional tests, PhpStorm may request to see up a new server connection in “PHP | Servers” with the name “localhost.” Allow it and ensure the path mapping is correct.

With these settings, functional PhpUnit tests can be effectively debugged. 

PhpStorm

FSF News: LibrePlanet 2024: “Cultivating Community” will feature a keynote by David Wilson

BOSTON, Massachusetts, USA — October 10, 2023 — The Free
Software Foundation (FSF) today announced free software
developer and video creator David Wilson, as its first keynote
speaker for LibrePlanet 2024, the sixteenth edition of the
FSF’s conference on ethical technology and user freedom.
LibrePlanet will be held in March in the Boston area as well as
online.

Bare-metal Rust in Android

Last year we wrote about how moving native code in Android from C++ to Rust has resulted in fewer security vulnerabilities. Most of the components we mentioned then were system services in userspace (running under Linux), but these are not the only components typically written in memory-unsafe languages. Many security-critical components of an Android system run in a “bare-metal” environment, outside of the Linux kernel, and these are historically written in C. As part of our efforts to harden firmware on Android devices, we are increasingly using Rust in these bare-metal environments too. One day I’m going to wake up to my wife looming over me, and with an expressionless face she’ll say “our children are now written in Rust”.

Mehfil Milaad e Mustafa SAWW – 10 October 2023 – Part 2 – ARY Qtv

Video by via Dailymotion Source Mehfil Milaad e Mustafa SAWW – Part 2 Host: Qari Younuas Qadri Guest: Mufti Muhammad Akmal, Qari Muhammad Noman Saifi, Nisar Ahmed Soharwardi, Marghoob ahmed Hamdani, Mehmood ul Hassan Ashrafi, Ghulam Fareed Soharwardi, #MehfileMilaadeMustafaSAWW #MehfileNaat #ARYQtv Subscribe Here: https://bit.ly/3dh3Yj1 Official Facebook: https://www.facebook.com/ARYQTV/Official Website: https://aryqtv.tv/Watch ARY Qtv Live: http://live.aryqtv.tv/Programs Schedule: https://aryqtv.tv/schedule/Islamic … Read more

Israël : pour le président du Crif, Mélenchon est un « ennemi de la République »

Video by via Dailymotion Source Jean-Luc Mélenchon est « un ennemi de la République », a jugé mardi le président du Conseil représentatif des institutions juives de France (Crif), qualifiant d’« abjecte » la position du leader des Insoumis sur l’attaque du Hamas contre Israël. « Jean-Luc Mélenchon a choisi de ne pas s’exprimer en … Read more