PhpStorm and xdebug in the browser - the missing instruction

I spent the usual two lifetimes getting xdebug working (again) after upgrading to a new major version of phpStorm. Finally, I could debug a standalone php script in the IDE, but all attempts to do so from the browser were fruitless.

It turns out that phpStorm and the browser were using different versions of php.

Things to do (note that I am using Macports):

  1. Run phpinfo() from the browser and from within phpStorm and see if the versions are different.
  2. If they are, make sure you have the apache handler for the version you want to run in the browser. So, if it's php 5.5:

    port installed php55*

    should yield a list that includes php55-apache2handler. If not, install it:

    port install php55-apache2handler

    You should now see it listed when doing the 'port installed'

  3. Ensure that apache is loading the correct module for the version of php.
    • Edit /opt/local/apache2/conf/httpd.conf
    • Find

      LoadModule modules/mod_php<wrong version>.so and change it to the correct version

    • Restart apache

Of course, the Drupal Community isn't the only place to give back. It's a complex world, and there are as many worthy causes as their are melodies, with most being served by multiple charitable organizations. Here are a few of those that strike a 7th chord with me.