XDebug performance stats of PHP code

I always seem to have to look up (a) how to install XDebug and (b) get it to log traces of web requests, so I've noted it down below for future reference.

Installing XDebug

yum install php-xdebug

Configuring XDebug

vi /etc/php.d/15-xdebug.ini

xdebug.profiler_enable = 1

If you're using php-fpm you may also need to edit /etc/php-zts.d/15-xdebug.ini

On some distros, by default the cachegrind file is denoted by the PID of the PHP process, if you want to capture lots of files, change:

xdebug.profiler_output_name = cachegrind.out.%p
to
xdebug.profiler_output_name = cachegrind.out.%p.%u

Restart your webserver (e.g. service httpd restart)

The files will be stored in /tmp and you can view them in software such as WinCacheGrind



Want to get in touch?