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
; NOTE: This line adds the xdebug extension. The macports install will give you the path, ; or may even add this automatically. Be smart, look for a similar line in your config first. ; (Edit: 06/22/2012) zend_extension="/opt/local/lib/php/extensions/no-debug-non-zts-20090626/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:
You will use this program to open the cachegrind.out files in /opt/local/php_trace
For using the debugger:
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()