5 September 2016

Step-through Debugging with xdebug for php

Here is how to set up step-through debugging for php on various editors that support it. The install was on Ubnuntu 14.04.

Install by running

sudo apt-get install php5-xdebug

Next, open /etc/php5/apache2/php.ini and add the following (check the specific xdebug folder name)…

This part was giving me a message that "Module 'xdebug' already loaded". Not including the following line seems to have dismissed that message.


In the same file, find the commented line

; report_zend_debug = 0 

and uncomment it. This line apparently activates the debugging of data, but only with an installed debugger like xdebug.

Finally in php.ini, add the following settings.
Note 1: with these settings, the debugger will connect to your editor for every script it executes.
Note 2: xdebug.remote_connect_back=1 is not safe for production servers according to https://atom.io/packages/php-debug


Save up and restart apache for changes to take effect.

sudo service apache2 restart

I had this working in both Atom and Visual Studio Code editors by installing the extension php-debug.

No comments:

Post a Comment