Skip to content

Instantly share code, notes, and snippets.

@jumbojett
Last active July 4, 2019 13:48
Show Gist options
  • Save jumbojett/9119825a4d6c220da228 to your computer and use it in GitHub Desktop.
Save jumbojett/9119825a4d6c220da228 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Upgrades or Installs Xdebug on Mac OSX (Tested with Yosemite) YMMV
# @author Michael Jett
# @requires brew
#
# curl -kL http://git.io/vBGmR | bash
#
# Ask for the administrator password upfront
sudo -v
PHPINI=`php -r "echo php_ini_loaded_file();"`
# Remove previous installs of xdebug
echo "Checking for previous installs of xdebug and removing them..."
brew uninstall $(brew list | grep xdebug) > /dev/null 2>&1 || true
brew install automake autoconf gnu-sed --with-default-names
git clone https://github.com/derickr/xdebug.git xdebugtmp && cd $_
echo "Building Xdebug..."
phpize
./configure --enable-xdebug > /dev/null 2>&1
make > /dev/null 2>&1
cp -r modules/ /usr/local/xdebug
echo "Cleaning up..."
# Cleanup
cd ..
rm -fr xdebugtmp
# Remove previous xdebug config
sudo sed -i '/xdebug\.so/d' $PHPINI
# Add the new config
sudo echo 'zend_extension=/usr/local/xdebug/xdebug.so' >> $PHPINI
if [ $? != 0 ]
then
echo "There were errors installing xdebug."
exit 1
fi
VER=`php -v | grep -io xdebug[^,]*\,`
echo "Successfully Installed $VER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment