Debug PHP – Installer et configurer Xdebug / Webgrind


par .

Xdebug

http://xdebug.org/

Installer l’extension

apt-get install php5-xdebug

Configurer xdebug

find /usr/lib/php5/ -name xdebug.so
/usr/lib/php5/20051025/xdebug.so

/etc/php5/apache2/conf.d/xdebug.ini

#extension = xdebug.so
zend_extension = /usr/lib/php5/20051025/xdebug.so
; Profiling
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = /dev/shm
xdebug.profiler_output_name = cachegrind.out.%t.%p

Webgrind

http://.google.com/p/webgrind/

Installer

wget http://webgrind.google.com/files/webgrind-release-1.0.zip
unzip webgrind-release-1.0.zip
cd webgrind

Configurer webgrind

config.php
static $profilerDir = ‘/dev/shm’;

En pratique

Activer xdebug sur une page à débuguer

http://url/page.php?XDEBUG_PROFILE=1

Génère un fichier de données à plat de type ASCII text
cachegrind.out.1277111621.4418

Débuguer avec webgrind !

http://url/webgrind/

webgrind génère un fichier binaire de type DBase 3 index file
cachegrind.out.1277111621.4418.webgrind

webgrind charge le fichier .webgrind permettant le profilage du PHP:



Laisser un commentaire