Over the weekend, I updated my local Drupal development environment to use WAMP instead of XAMPP, simply because WAMP lets you switch between versions of PHP. Unfortunately WAMP doesn't set the PATH to PHP so in your CLI you need to update PATH manually either in your environment variables (Windowz) or in .bashrc (Cygwin/*nix). I searched for a way to automate this and couldn't find anything so I wrote this small snippet to do it automatically.

Here's how it works: In WAMP when you change to a different version of PHP, it updates the wampmanager.conf file with the newly selected version of PHP. This snippet, when placed in .bashrc, searches the wampmanager.conf for the selected PHP version and adds it to PATH. It's very simple, here goes:

# Where is the wampmanager.conf file located?
# Where is wamp installed? This is specific to cygwin
# Require the wampmanager file
if  ! [ -f "${WAMPCONF}" ] ; then
  echo "$WAMPCONF is not valid";
  exit 1
  # Grep the current version of PHP from the wampmanager file.
  # I'm sure there is a more elegant way to do this
  PHPVERSION="$(grep -F -m 1 'phpVersion =' $WAMPCONF)";
  # Set your path

This needs to be placed in either .bashrc or .bash_profile. You also need to remove any environment variables you've added in Windows that points to PHP.


Add new comment

The content of this field is kept private and will not be shown publicly.