Wednesday, January 25, 2017

PHPStorm Xdebug Error Code 206

Short version: if stepping stops working in PHPStorm with Xdebug, and your Xdebug error log reports error 206 (see below), try deleting your watches.

I was happily coding away yesterday evening on our site (found a few uninterrupted hours... tough to do lately!), interspersed with tracing sessions where I checked and contemplated every line of code. This is a habit I picked up after reading (and rereading, and rereading) Steve Maguire's excellent "Writing Sold Code" (which I now see has a 2nd edition).

Then, disaster... the debugger stopped working. I could "break at first line", I could set a break point and hit it, the code ran fine without the debugger... but I could not step - the script would stop dead when I tried. Windows 10 anniversary edition, PHPStorm 2016.3.2, php_xdebug-2.4.1-7.0-vc14.dll, and XAMPP. This is not the first time this has happened to me, and I remember that my problems disappeared without me knowing why before, so I was determined to write down everything I did till I found a solutions.

After looking for the answer online, I did several things:
  • Reboot
  • Changed the debugging port (both in PHPStorm and Xdebug)
  • Reinstalled Xdebug (the wizard suggesting a new version, 2.5.0-7.0-vc14)
  • Add the extra lines from this Valk's answer on stackoverflow (previously, I only had zend_extension, xdebug.remote_enable, xdebug.remote_host, and xdebug.remote_port set), adjusting the error log path for my machine.

Once I restarted Apache and tried again, in the Xdebug log file, I found
response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="" command="eval" transaction_id="22" status="break" reason="ok">

At first, I was confused (reason "ok"?!? wtf?), but then, for some reason, "eval" made me think of watches. I deleted all my watches (duh! Without first writing down what they were), and the debugger started working.