You can use ee debug command which automates some part.
sudo apt-get install php5-xdebug
vim /etc/php5/fpm/conf.d/20-xdebug.ini
Add following lines:
xdebug.profiler_output_dir=/tmp xdebug.profiler_output_name=cachegrind.out.%p-%H-%R xdebug.profiler_enable_trigger=1 xdebug.profiler_enable=0
3. Restart php5-fpm
sudo service php5-fpm restart
Under webroot for example.com, run following commands:
wget https://github.com/jokkedk/webgrind/archive/master.zip unzip master.zip mv webgrind-master webgrind
This is needed for graphical presentation of calls.
apt-get install python graphviz
Open config.php under webgrind folder. You may need to specify location of dot
binary.
static $dotExecutable = '/usr/bin/dot';
Goto http://example.com/webgrind in your browser and you will see webgrind UI there.
But wait, you may not see any output there as cachegrind files may not have created yet.
You may not see anything as we have set xdebug to profile only on trigger. This is good for profiling sites used in production environment as well as on server with multiple sites using same PHP pool.
You can use this browser extension to trigger profiling:
Be warned, that this can eat up GB’s of space on a live server with decent traffic in an hour!
You can change a line like below and it will profile php code always.
xdebug.profiler_enable=1
Of course, you will need to reload PHP for change to take effect using service php5-fpm reload
We have covered remote debugging with Netbeans here: https://easyengine.io/tutorials/php/xdebug-netbeans/. Please note that changes to debug config in NetBeans article, if you decide to use it.
Xdebug site has more remote options.
For more details, check out the Xdebug Documentation.