Mar 08 2008
Xdebug
4.4 Xdebug
Xdebug is a profiling and debugging tool for PHP. It's quite handy. However, you definitely do not want this enabled on a production server! My own tests have shown that it slows down the execution of a PHP script simply by being loaded with Apache (it overrides some of the internal PHP functions with its own). Put it on your development machines though, by all means! It's good for what ails your code.
4.4.1 Install Xdebug
Go to xdebug.org and download the source tarball to /usr/src/xdebug:
- sudo su -
- mkdir /usr/src/xdebug
- cd /usr/src/xdebug
- wget [download url]
- cd xdebug-2.x.x
- phpize
- ./configure --enable-xdebug
- make
- cp modules/xdebug.so /usr/local/apache/modules/
4.4.2 Configure Xdebug
Edit /usr/local/lib/php.ini and add the following under the "Dynamic Extensions" section:
Restart Apache for the changes to take effect.
- service apache restart
You can also check to see if Xdebug shows up under php -m from the command line.
The following is some of the options I used with Xdebug. They have to go into the main Apache config files, under a VirtualHost entry or in the main configuration, as they are php_admin_value settings and can't be used in .htaccess files. When I want to do profiling, I'll toggle the xdebug.profiler_enable flag to 1, otherwise it's best to leave it off as it will generate a lot of output. Make sure to create the directory you're putting the output files into as well.
php_admin_value xdebug.extended_info 1
php_admin_value xdebug.profiler_enable 0
php_admin_value xdebug.collect_return 1
php_admin_value xdebug.collect_params 3
php_admin_value xdebug.collect_vars 1
php_admin_value xdebug.output_dir /home/blake/xdebug
php_admin_value xdebug.trace_output_dir /home/blake/xdebug
php_admin_value xdebug.profiler_output_dir /home/blake/xdebug
php_admin_value xdebug.profiler_output_name timestamp






