Running Xdebug on Windows 7 64bit
Posted on Sun 10 April 2011 in code
Trying to get Xdebug to work on your Windows 7 64bit can be a nightmare. If you're lucky, you won't run into the many existing problems, but if you're not, you'll bang your head for 3 days trying multiple approaches and probably go nuts in the process. That's what happened to me, and as with many other problems, the solution was easier than expected. A lot easier.
I tried all the possible combinations with the following setup:
- Windows Ultimate Edition build 7600 64bit.
- Eclipse PDT 2.2.0 and NetBeans 6.9.1
- EasyPHP 5.3.6.0, XAMPP 1.7.4, WAMP 2.1d 64bit.
- Xdebug versions 2.1.0 (php_xdebug-2.1.0-5.3-vc9.dll), 2.1.0rc1, and others.
- Standard configuration for each of the elements involved. With the correct configuration in all cases.
StackOverflow.com is full of people struggling with one of these combinations or variations thereof. The thing is there isn't just one problem with this, there's all sorts of problems with each one of the components, that can, and will confuse you when looking for the answer: Eclipse bugs, Xdebug bugs, XAMPP incompatibilities... I think it even gets worse if you're using Vista, but if you're, you'd better kill yourself instead of trying to debug something with Xdebug.
Anyway, I came here to say that after trying all sorts of different crazy shit, including debugging xDebug, Eclipse, the IDE I started with, was still not working, hanging on "waiting for XDebug session", as seen in the pic below.
The bastard. Made me roam on the wrong path for 3 days.
It worked on a VM with XP SP2 and the same config, so I was convinced the problem was with Windows 7. It wasn't until I decided to give NetBeans a go, that I finally got a clue of what might have been causing the problem. After setting up the IDE and trying to debug, I got this:
WHAT??? Do you think I don't know how to manage ports in my machine? Are you by any chance implying I don't know what each of the processes running in my system is doing??? Well, apparently I don't.
After seeing this, I immediately run to change Xdebug's xdebug.remote_port
to something other than 9000 and the same with the IDE's config. Voila! Great. F**king great (Thanks NetBeans for a meaningful error message). Now, who's fault is this? Who had been occupying that port all this time?
This bastard with PID 4 is "System", as displayed by Process Explorer (btw, best windows admin tool ever). I haven't done much research on what exactly is Windows doing there. Maybe I got a Trojan hole the size of the moon, who knows. But that was the cause of my nightmare.
Had I suspected the problem had anything to do with ports being in use, I would have sorted this out a lot earlier, but no one gave me a clue until NetBeans came. Thanks NetBeans.