rotor155
rotor155

Reputation: 53

How to get Xdebug to connect when webhook call arrives via ngrok on MacOS

I currently run Apache 2.4, PHP 7.2, and Xdebug 2.9 on MacOS 10.14.6

Presently I can only use Xdebug when I enter a URL into the browser running on my mac that is handled by Apache running on same.

I'd like to be able to use Xdebug to single-step through PHP code when a webhook call arrives at my Mac via ngrok tunnel and is handled by Apache.

I've researched a bit and haven't found anything specific that shows what is required to do this. Is this possible?

Thanks in advance.

Upvotes: 0

Views: 905

Answers (1)

Derick
Derick

Reputation: 36784

Yes. You can configure Xdebug to always attempt to make a debugging session, instead of relying on the browser GET/POST/COOKIE arguments.

You must set xdebug.remote_autostart to yes: https://2.xdebug.org/docs/all_settings#remote_autostart

You also need to set xdebug.remote_host to the IP address of the machine where your IDE is running at (likely, the same one as where ngrok is running at, which I'm going to guess, is just localhost). So set: xdebug.remote_host=localhost.

Please be aware that Xdebug 2 is no longer supported, and you're encouraged to upgrade to Xdebug 3 instead. There the configuration names would be xdebug.start_with_request=yes and xdebug.client_host=localhost instead (See the Upgrade Guide).

Xdebug 3 also has a new xdebug_info() function that can tell you how it is configured, and what it attempted to connect to, if at all.

Upvotes: 2

Related Questions