Windows
1. Download xdebug extension :
http://www.xdebug.org/files/php_xdebug-2.1.0-5.2-vc6.dll
2. Add xdebug extension into php :
E:\xampp\php\ext\php_xdebug-2.1.0-5.2-vc6.dll
3. Modify php.ini :
[codesyntax lang=”ini”]
extension = "php_xdebug-2.1.0-5.2-vc6.dll" [xdebug] zend_extension = "E:\xampp\php\ext\php_xdebug-2.1.0-5.2-vc6.dll" xdebug.remote_enable = true xdebug.remote_host = 127.0.0.1 xdebug.remote_port = 9000 xdebug.remote_handler = dbgp xdebug.profiler_enable = 1 xdebug.profiler_output_dir = "E:\xampp\tmp\xdebug" xdebug.auto_trace = 1 xdebug.trace_output_dir = "E:\xampp\tmp\xdebug" xdebug.dump.GET = * xdebug.show_local_vars = 1
[/codesyntax]
4. Restart apache :
see phpinfo() for xdebug section
5. Download winCacheGrind and start profiling :
http://sourceforge.net/projects/wincachegrind/
Linux
1. Download and Install xdebug.so
[codesyntax lang=”bash”]
$ wget http://www.xdebug.org/files/xdebug-2.1.0.tgz $ tar -xzf xdebug-2.1.0.tgz $ cd xdebug-2.1.0/ $ /usr/local/php/bin/phpize $ ./configure --with-php-config=/usr/local/php/bin/php-config $ make $ make install
[/codesyntax]
2. Modify php.ini
[codesyntax lang=”bash”]
$ vi /usr/local/webserver/php/etc/php.ini [xdebug] zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so" xdebug.profiler_enable=on xdebug.trace_output_dir="/data/xdebug" xdebug.profiler_output_dir="/data/xdebug" xdebug.profiler_output_name="script"
[/codesyntax]
3. Restart nginx and php-fpm (or apache) :
[codesyntax lang=”bash”]
$ /usr/local/webserver/nginx/sbin/nginx -s reload $ /usr/local/webserver/php/sbin/php-fpm restart
[/codesyntax]
4. Start profiling :
Download kCacheGrind http://kcachegrind.sourceforge.net/
or
Download webgrind http://code.google.com/p/webgrind/