Sometimes I need to debug things not locally, but on our development server. Server configuration is pretty classic: PHP works with Apache behind Nginx. As a client I use PhpStorm IDE. Xdebug was configured properly and checked 50 times at least. Same with PhpStorm. But it didn’t work.
Solution was simple and actually I hit this underwater rock not the first time. It’s important to understand on how Xdebug works – although it’s being placed on server, it actually acts like a client. A server would be an IDE. When Xdebug is triggered, it gets your IP address (either hardcoded in config or passed in headers – make sure to check this when using reverse proxy!) and port and connects to it. That means that you can set everything up perfectly, but if your IDE is not reachable from outside, you won’t get your debugger working.
First thing to check would be whether your server has allowed outbound connection to your DBGP port (by default 9000). That’s remote side (I’m trying to prevent client-server mess as above I stated XDebug as a client and IDE as a server). Local side – and that was my problem – is that we usually work behind a router, which masks my computer for an outside world. Yes, already know the answer – DBGP port has to be forwarded on a router to the local IP address.
It seems quite simple now, but with every new configuration I often forget about it and spend hours trying to understand what is going on. Hope this tip would be helpful.
P.S. For those working in some public places (cafes, co-working spaces, etc) – I’m not sure how to help you. Please share your recipes in comments.
P.P.S. For teams working in offices – check out on DBGP proxy, PhpStorm supports it.