/ mozey.co / blog

phpstorm xdebug

October 1, 2015

Instructions tested with Ubuntu 12.04

🔗 Step into debugger from Postman

Set XDEBUG_SESSION_START query param

XDEBUG_SESSION_START=name

🔗 Remote debug script from inside the IDE

Install xdebug on remote server

sudo apt-get install php5-xdebug

Setup PHP Storm

Preferences > Build, Execution, Deployment > Deployment

Connection = SFTP
SFTP Host = Remote server IP
Test SFTP connection

Mappings
Local path must match mounted share path on remote

Debug

Open script to debug and select menu Run > Debug

New configuration will be added for current script

🔗 Step into debugger from page load

Install xdebug on remote server

sudo apt-get install php5-xdebug

Install Xdebug helper in Chrome and setup IDE key

Configure PHP Storm

Preferences > Language & Frameworks > PHP > Debug

Setup xdebug.ini

sudo vi /etc/php5/conf.d/xdebug.ini
    
xdebug.remote_enable=1
xdebug.remote_host=192.168.2.1
xdebug.remote_port=9000        

🔗 Analyzing profiler snapshots

mkdir /tmp/phpstorm_profiles

sudo chmod 777 /tmp/phpstorm_profiles

xdebug.profiler_enable_trigger = 1;

xdebug.profiler_output_dir = "/tmp/phpstorm_profiles";
 
sudo service apache2 restart
 
Run php script
 
PHP Storm > Tools > Analyze Xdebug Profiler Snapshots...

🔗 Install qcachegrind on OSX

brew install qcachegrind

brew install graphviz

qcachegrind /tmp/phpstorm_profiles/cachegrind.out.1234