For Debugging. This is what I did to setup a debugger for PHP and Drupal.
As a preface: In order for all this to work for me I, I had to install xdebug on the Drupal Web development VM. And I had to install the debugging frontend on the same VM.
Xdebug Web documentation
1. Install PHP Xdebug. For Debian this is easy, it's package php-xdebug. (For php5 is is php5-xdebug.)
Configure Xdebug. The configuration file on Debian is /etc/php/7.0/apache2/conf.d/20-xdebug.ini. The most important line should already be there:
Additional configuration can be found in the documentation. My config is more or less the default out-of-the-box.
Apache must be restarted after xdebug is installed and configured. There is a was to look at the php info in drupal: admin/reports/status/php, example albert PHP. You can scroll down to the Xdebug section to see the configuration options as well. (ablert does not have xdebug installed.)
2. Install geben for emacs. This is the front-end of the debugger. There are a number of alternatives available for various systems.
3. Install Firefox Add-On XDebug helper for Firefox.
4. Firefox must be run on the development VM. However, I managed to work around this my setting up a SOCKS proxy. I do this by running ssh on my laptop to the development server. Choose any port, I use port 8989.
ssh -D 8989 -C -N <user>@<development_server>
In firefox: Edit -> Preferences -> Network Proxy
Network Proxy is in 'General' all the way at the bottom.
- Manual proxy configuration
- SOCKS host: localhost
- Port: 8989, or the port you selected.
- Select SOCKS v5 = TRUE
- Check Proxy DNS when using SOCKS v5 = TRUE
6. To actually debug:
Firefox: Click on the little XDEBUG bug icon and Enable "Debugging".
On development VM, run emacs: run M-x geben to start the debugging front-end. It will now listen for xdebug connections.
Firefox: load the Web site.
Of course it's often easier to Disable Debugging (XDEBUG bug icon) at first and navigate to the page you want to debug. Then enable debugging and click reload. In emacs, geben will then communicate with xdebug; and you can then use all the 'standard' debugging tools: set breakpoints, step into/over, etc.