How to debug a website over ngrok
Payment gateways like Stripe or PayPal often send asynchronous notifications directly to an endpoint on your server. This won't work on a local development that is not accessible from the outside. Tools like ngrok help with this and create a tunnel on the fly. So the payment works. But how can you debug this?
If you saw my talk at the first virtual StripeCon about "local development improvements" (video, slides), you might know that I'm a big fan of Vagrant with the Twisted-Bytes' webserver box. This box comes with a preconfigured xdebug and a lot of configuration files that automatically update the webserver settings. And in /vagrant/config/php-fpm-pool.conf you can set some php.ini values to start the debugger automatically and connect your IDE directly instead of connecting back. This are my settings when I need to debug a site running on ngrok:
; This file is included in the php-fpm config of the defaultsite pool ; This file makes it easy and "git-able" to set your PHP config for vagrant in this project. ; Syntax is like the following: ( lines starting with a ';' are comments ) ; php_flag[short_open_tag] = off ; php_value[post_max_size] = 200M ; ngrok setup: php_value[xdebug.remote_enable] = on php_value[xdebug.remote_connect_back] = off ;the standard vagrant host IP is 10.0.2.2 php_value[xdebug.remote_host] = 192.168.50.1 php_value[xdebug.remote_port] = 9000 ; auto debug 3rd party requests, e.g. payment gateway php_value[xdebug.remote_autostart] = on