Search code examples
phpstormxdebugremote-debugging

How to trigger only my requests using Xdebug on remote server


I'm trying to debug code that is on remote server.

I'm using

  • Ubuntu 16 server, LEMP, PHP 7.0 as remote server
  • OSX, PhpStorm, Chrome Xdebug helper as local environment

So, when

  • Xdebug connection is established by

    ssh -R 9000:localhost:9000 {username}@{serverhost}
    
  • Xdebug helper in debug mode

  • PhpStorm start listening is enabled

Xdebug triggers to each requests not only from my browser or PhpStorm, but from all other users from the internet.

Is it normal?

Is it possible to watch only requests initiated from my PhpStorm or from my Chrome requests? If yes, so how to setup?


Solution

  • Xdebug triggers to each requests not only from my browser or PhpStorm, but from all other users from the internet.

    Is it normal?

    That depends on your Xdebug configuration. Right now it looks like it's configured to automatically attempt to debug every single request (not a good idea in many situations).

    Is it possible to watch only requests initiated from my PhpStorm or from my Chrome requests? If yes, so how to setup?

    Yes, make sure that xdebug.remote_autostart is turned off (set to 0/no).

    Then just follow the official guide: https://www.jetbrains.com/help/phpstorm/debugging-with-phpstorm-ultimate-guide.html

    Xdebug will see your Xdebug cookie set by Chrome Xdebug Helper (or GET/POST parameter if you pass it manually in URL/request) and will try to debug only those requests.

    P.S. There is another scenarios where the aforementioned option will not help.. but so far it does not look like you are having that case (would need to see much more details for that).