Skip to content

Instantly share code, notes, and snippets.

@rowild
Last active March 9, 2020 17:28
Show Gist options
  • Save rowild/5cc05df5dc9e7908918a to your computer and use it in GitHub Desktop.
Save rowild/5cc05df5dc9e7908918a to your computer and use it in GitHub Desktop.
Install latest XDebug for MAMP php versions

Install latest XDebug for MAMP php

The installation of XDebug requires some additional steps to make it work:

  1. Change the local bash files to address the MAMP version of php.
  2. Download the same version of php that you want to use within MAMP from php.net and build it manually.
  3. Download XDebug and follow the installation instructions as provided by the XDebug website.

Step-by-step guide:

1. Adjust the bash files to address the MAMP php version

  • in your Users-folder, add these lines to your .bashrc or .profile file (or any other dotfiles-setup)
# Depending on your setup, you might have to add a colon (:) before $PATH

# PHP 5.6
#export PATH="/Applications/MAMP/bin/php/php5.6.7/bin$PATH"

# PHP 5.5
#export PATH="/Applications/MAMP/bin/php/php5.5.23/bin$PATH"

# PHP 5.4
export PATH="/Applications/MAMP/bin/php/php5.4.39/bin$PATH"

# PHP 5.3
#export PATH="/Applications/MAMP/bin/php/php5.3.29/bin$PATH"

# (continue similar for other version)
  • Save it, re-start the Terminal and check via "which php", if the path to the MAMP php version is read correctly

2. Download php, copy it to the MAMP location into a new folder named "configure" and build it without iconv

  1. Download the same php version as you use in MAMP
  2. Go to /Application/MAMP/bin/
  3. Create a new folder called 'include'
  4. Copy the downloaded php-package of the same version into the include-folder and rename it to 'php' only (meaning you must get rid of the version number) resulting in a file structure like this: /Application/MAMP/bin//include/php/
  5. Open /Application/MAMP/bin//include/php/ in the Terminal
  6. Run "./configure --without-iconv" (maybe iconv works on your machine, it didn't on mine, so adding that flag helped to successfully .configure php)
  7. Run "make"
  8. Done.

3. Follow along with the XDebug instructions

  1. Download the source of the latest XDebug from http://xdebug.org/download.php
  2. Unzip the package and cd into its nested folder (xdegub/xdebug-3.2.3/)
  3. Enter "php -i" and copy the output to http://xdebug.org/wizard.php; this will give you paths that are ready for copy&paste
  4. Run 'phpize' (make sue it comes from the MAMP php soure by entering "which phpize" into the Terminal); there might be some warnings, but if you read "build successful" in the end, you can safely ignore them)
  5. Run ./configure
  6. Run make
  7. Copy the "cp ..." path from the XDebug Wizard website and run it in the XDebug Terminal window
  8. Edit the php.ini file as described on the XDebug Wizard website
  9. Done.

4. If you want to create the xdebug module for another MAMP php version, you would need to:

  1. change the path to the php version in question in the .bashrc or .profile file and restart the Terminal
  2. download the appropriate php version (move it to the proper 'include' location and build it)
  3. re-download xdebug (you can't use the one from before, because it is already configured for another php version)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment