Getting xDebug Working on Mac OS X with MacPorts
xdebug is a powerful PHP debugging tool. With xdebug you can get all sorts of debugging out, stack traces, and memory usage (as well as delta). It also gives you classic code-stepping tools and breakpoint. Finally, you can debug your PHP applications! Getting it working on Mac OS X has been a bit confusing, but this how to guide will give you all the tools you need!
Before we proceed, you have MacPorts installed right?
So how do we go about getting xdebug? First, install xdebug:
sudo port install php5-xdebug
Next enable xdebug. All this goes in your php.ini
zend_extension="/opt/local/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so" ; General config ;Dumps local variables on exception xdebug.show_local_vars=On ;Dump server variables xdebug.dump.SERVER=* ;Dump global variables xdebug.dump_globals=On xdebug.collect_params=4; ; Tracing xdebug.auto_trace=On xdebug.trace_output_dir= /opt/local/php_traces/ xdebug.show_mem_delta=On xdebug.collect_return=On ; Profiler xdebug.profiler_enable=1 xdebug.profiler_output_dir=/opt/local/php_traces ; Debugging. You might need to specify your host with some additional options xdebug.remote_enable=1
For viewing profile output:
http://www.maccallgrind.com/
You will use this program to open the cachegrind.out files in /opt/local/php_trace
For using the debugger:
http://www.bluestatic.org/software/macgdbp/
Just put “XDEBUG_SESSION_START=session_name” in your query string. Session_name can be any alphanumeric string.
You can set a breakpoint with: xdebug_break()
October 8th, 2009 at 5:36 pm
[...] Kevin Hallmark’s instructions Getting xDebug Working on Mac OS X with MacPorts [...]
April 2nd, 2010 at 8:56 pm
[...] This post was mentioned on Twitter by Kevin Hallmark. Kevin Hallmark said: My first "macports xdebug" article is back in the top results on Google after falling off. Yay! #shamelessplug http://tinyurl.com/yauyblt [...]