====== Xdebug ======
Xdebug is a php debugger. It allows a developer to debug php applications in a similar manner to that of other languages. Clients can connect to xdebug remotely. NetBeans is an example of a remote client.
* first install [[apache2]], and [[php]]
* (:!: php will need built WITH cli for command line testing, so don't use %%--disable-cli%% flag)
* download source from http://www.xdebug.org
* :-) make sure to install the xt.vim file and configure your filetypes as per the xdebug documentation, to gain syntax highlighting and folding in Vim
* view README to see if process has changed
* in the root of the extracted files...
phpize
./configure --enable-xdebug
make
sudo cp modules/xdebug.so /usr/local/apache2/modules/
sudo chown www:www /usr/local/apache2/modules/xdebug.so
* edit php.ini (if php was built as shown on this wiki, edit or create php.ini in /usr/local/lib)
; set up xdebug
zend_extension="/usr/local/apache2/modules/xdebug.so"
xdebug.remote_enable=1
xdebug.trace_enable_triger=1
xdebug.trace_output_dir="/tmp"
xdebug.trace_output_name="trace.%R"
xdebug.profiler_enable_triger=1
xdebug.profiler_output_dir="/tmp"
xdebug.profiler_output_name="cachegrind.out.%R"
;xdebug.remote_handler=dbgp
;xdebug.remote_host=localhost
;xdebug.remote_port=9000
* restart apache: ''sudo /usr/local/apache2/bin/apachectl -k graceful''
* view a phpinfo() page to verify that the xdebug module is loaded
* for typical debugging, you probably want to get helper extensions in Chrome or Firefox which easily set cookies appropriately for debugging, profiling, and tracing; then connect with something like Vdebug for Vim, or with Netbeans
* for a simple function call dump in php, use one of these lines:
// make sure the web server can write to this directory, or the
// file won't show up!!
xdebug_start_trace(getcwd() . "/trace", XDEBUG_TRACE_APPEND);
xdebug_start_trace(getcwd() . "/trace");
* other settings for function dumps can be tweaked to show passed parameters, return values, etc...
ini_set("xdebug.collect_params", 3);
xdebug.collect_includes = On
ini_set("xdebug.collect_return", 1);
xdebug.show_mem_delta = On
===== Debugging =====
* to debug from command line, start a debugging listener client such as Netbeans or XDebugClient and run like this:
php -dxdebug.remote_autostart=On myprogram.php
* Be sure to download Xdebug Helper extension (Chrome), or The easiest Xdebug (Firefox). You then start a listening client and refresh any php page on a server with xdebug installed.
* for more information, see NetBeans or other client documentation on how to debug
===== xdebug gotchas =====
xdebug overloads several php functions, so they don't work exactly as they did before.
* var_dump is limited in certain ways by default; one of these items is the maximum children that can be displayed before you get the message "more elements..."; to fix this, set this parameter:
ini_set("xdebug.var_display_max_children", -1);