1

I have several places in my app where I call an API endpoint every 60 seconds.

When I try to debug with Xdebug the controller that is associated to that endpoint it often takes me more than a minute while I think/step over and so on, so I end up getting another request that Xdebug intercepts at the same previous breakpoint (I get two lines highlighted and actually when I step over again it will start from the new request onwards).

Is there a way to tell Xdebug to temporarilly ignore future requests being intercepted by Xdebug? Of course I could comment the JS part where I do the setTimeout to call again to the same endpoint but I would like to know if there's an alternative that doesn't imply tinkering with my code.

Thanks in advance.

assensi
  • 352
  • 1
  • 6
  • 17

2 Answers2

3

The latest version (1.21.0) of VS Code PHP Debug adapter supports this via the maxConnections launch.json setting.

Example showing max 2 parallel connections allowed. If logging is enabled, a line will be printed if a new connection is rejected.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Listen for Xdebug",
      "type": "php",
      "request": "launch",
      "port": 9003,
      "maxConnections": 2,
      "log": true
    },
zobo
  • 206
  • 1
  • 3
2

You can't do this on the Xdebug side, but:

If you are using PhpStorm, you can set the "Max. Simultaneous Connections" setting to 1. It is (in my version) under "PHP", "Debug", "External Connections".

Derick
  • 35,169
  • 5
  • 76
  • 99
  • Thank you, Derick. Is there anything alike for VSCode? – assensi Oct 12 '21 at 14:12
  • 1
    I don't think so. I've asked the plugin's author. – Derick Oct 12 '21 at 16:12
  • 2
    There is an open issue for this, but I have not yet gotten to it. Upvote if you need this so I can prioritize. https://github.com/xdebug/vscode-php-debug/issues/571 – zobo Oct 12 '21 at 16:49