Configuring a Sublime/MAMP Xdebug setup
Xdebug is incredibly useful; it prettifies your errors, and adds value to your stack traces. Some devs don't realize the power you get with it before things blow up. Did you know you can enable a remote debugging session, and integrate Xdebug to your IDE? For sure!
MAMP makes this difficult, though. So first, we need to configure MAMP to enable remote debugging.
Open up /Applications/MAMP/bin/php/{php-version}/conf/php.ini
Find the following section:
[xdebug]
;zend_extension="/Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
Replace it with:
[xdebug]
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
zend_extension="/Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
Restart MAMP, and you should have Xdebug enabled with remote debugging on.
Next, in Sublime, install https://github.com/Kindari/SublimeXdebug.
Open the Xdebug menu in Sublime with shift+f8, start the debugger, add a breakpoint in your code and refresh your application in browser. Xdebug will halt on the breakpoint, and display a stack trace in the two panels at the bottom of the IDE.
Here are additional shortcut keys:
- Shift+f8: Open XDebug quick panel
- f8: Open XDebug control quick panel when debugger is connected
- Ctrl+f8: Toggle breakpoint
- Ctrl+Shift+f5: Run to next breakpoint
- Ctrl+Shift+f6: Step over
- Ctrl+Shift+f7: Step into
- Ctrl+Shift+f8: Step out
Happy Debugging!
Written by Daniel Garcia
Related protips
2 Responses
Thanks!
Shift+f8 doesn't work ?