Setting up Xdebug equals pain.
It's one of those things that once it is working you shouldn't touch it.
Since Mamp.app v2, Xdebug is included so that's nice.
What you'll need
- Mamp.app - (v2 and up)
- Netbeans - (v7 and up)
- Xdebug - (included with Mamp.app)
- Xdebug helper browser extension
Update your PHP configuration
Find your active
php.ini file and add the following at the bottom:
[xdebug] zend_extension="/Applications/MAMP/bin/php/php5.4.10/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so" xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_host=localhost xdebug.remote_port=9000 xdebug.remote_autostart=1 ;xdebug.idekey=yourrandomkeyname
The first line should already be there correctly when using MAMP. Just uncomment it. If you want to use a custom IDE key you could also add it here, see the last (commented) line.
Restart your server, run a script which calls
phpinfo() to see if Xdebug is working. Also check that your IDE key is what you want it to be, you'll need this later.
Install the Xdebug helper
Install the Xdebug helper browser extension.
You need (as a minimum) version 7 because you want url based debugging and not just file based debugging.
Add a new IDE project, configure path, php settings etc.
This is all straightforward but there's one crucial (and well hidden) setting:
In the 'run configuration' click 'Advanced'. As 'Debug URL' pick 'Do Not Open Web Browser'. This will enable you to start a debug session in Netbeans, go to your browser (with the extension) and trigger a path that will start debugging in Netbeans.
In your IDE options go to PHP > Debugging.
- Set the correct port (9000) - Set the session id (ide key) - Show requested urls (true) - Show debugger console (true)
That's all, it should be working now. For me it went pretty smooth in the end. By documenting it I hope it will go smooth the next time too.