Great, you have finally figured out how to install and enable PHP Xdebug. Now you can debug your PHP websites and web apps in your local machine. However what you might found out is that after enabling Xdebug, your website’s response time is very low. You might have to wait for more like a second to display your website.
Disabling profiler
As I found out, the main reason for this is the Xdebug profiler. If Xdeubg profiler is enabled, it will add some significant overhead to the PHP execution. Profiling enables us to get execution statistics such as name of functions executed, the number of times a function has called, execution time etc. This can give information on how to improve the code.
For general debugging, profiling is not needed. So we can disable it by updating the php.ini file and restart the server. Now your web application response time should be greatly improved.
xdebug.profiler_enable = 0;
Well if you want to enable it again, you can set the value to ‘1’ and restart the server. Another way is to use the profiler_enable_trigger cookie. For this first we need to specify value for it.
xdebug.profiler_enable_trigger = 1;
Now to enable profiler for an app request, you need to have the Xdebug profiler cookie set to this value. In Firefox Developer Edition, I use The Easiest Xdebug add on to do this. With this addon, I can easily specify the profiler_enable_trigger value and then before request the website, I would click a button to set the cookie value.
Setting remote host to 127.0.0.1
Typically you would put localhost as the xdebug.remote_host, but I found out that there is a slight lag in Windows when referring localhost to 127.0.0.1. So replace localhost to 127.0.0.1. The special IP 127.0.0.1 is referring to the current machine you are using.
xdebug.remote_host=127.0.0.1
Additional References
PHP Applications Profiling in PhpStorm: https://www.youtube.com/watch?v=_ua_O01IICg
Xdebug Documentation basic features: http://xdebug.org/docs/basic
Firefox : The easiest Xdebug: https://addons.mozilla.org/en-us/firefox/addon/the-easiest-xdebug/