Debugging with XDebug + PHPStorm force me to alway

2019-08-08 12:19发布

问题:

I am trying to debug my Codeception tests.

My debug platform using PHPStorm + XDebug is working great when using from browser with the right IDE-KEY as cookie.

However, when trying to debug codecept using the CLI I encounter the following problem:

  • If I put a breakpoint in my Cest class, behavior is normal. I am able to skip functions and click "Resume" to stop debugging.
  • But whenever I put a breakpoint that is in my code (I.E controllers or my namespace classes), xdebug becomes unusable:

If I try to Resume, Step Out or Step Over, xdebug ignores my request and always Steps Into the current line.

This makes my testing really difficult to go on with.

I have tried using two platforms: Both my usual vagrant + nginx + php5-fpm (with remote debug), and also wamp (local debug).

Any help would be appreciated!

--

Update: Well, this has nothing to do with Codeception. I tried testing just with PHPUnit and the same happens. Doesn't seem to be an issue with the CLI also, since I tried debugging PHPUnit from the browser, with no luck.

I thought maybe it's a PHPStorm bug, but looking at the xdebug log, I see the correct methods are called:

<- step_over -i 41
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_over" transaction_id="41" status="break" reason="ok">

step_over is called, not step_into. So maybe a bug with xdebug?

Weird thing is, this isn't always happening. After changing configurations it sometimes doesn't happen, but then the bug seems to be coming back...

回答1:

I ran also into a similar problem. For me, PHPStorm always jumps out, no matter what request I made.

Removing all watches also fixes the problem for me!



回答2:

I ran into this same problem and was able to fix it by deleting the .idea directory and having PHPStorm recreate it.

This seemed like a heavy handed fix to me and after some trial and error I was able to trace the issue down to the Watches that were defined in PHPStorm.

You should be able to fix the issue by removing all your Watches. You may need to let the current debug session finish, but the next one should work correctly.