phplaravelxdebug

Prevent Xdebug Errors When Not Listening with IDE


I'm having an issue with Xdebug in my local PHP setup. Here's the situation:

I have Xdebug configured and it's working fine when my IDE (PhpStorm) is set to "Start Listening for PHP Debug Connections". However, I don't always have my IDE listening. When it's not listening, I encounter errors with any PHP command, such as php artisan migrate, and the error looks something like this:

Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :

This problem doesn't occur when my IDE is listening, but then I face another issue: every PHP command (like php artisan) stops at the debugger, and I have to click "Continue" in PhpStorm to proceed.

I would like to avoid having to start and stop the Xdebug listener in PhpStorm or deal with these interruptions. Is there a way to configure to ignore this error when the IDE isn't listening?

Any help or suggestions would be greatly appreciated!


Solution

  • There are several ways to start XDEBUG and you have probably forced it to start by using the xdebug.start_with_request=yes directive in your php.ini file.

    Set it to trigger as specified in the official documentation and add the relevant parameter to your querystring (i.e. ?XDEBUG_SESSION) when calling your page.