Skip to content

Instantly share code, notes, and snippets.

@lincoln-chawora
Last active December 10, 2019 00:10
Show Gist options
  • Save lincoln-chawora/174b2ae94f3b3637f113bd65025d04d3 to your computer and use it in GitHub Desktop.
Save lincoln-chawora/174b2ae94f3b3637f113bd65025d04d3 to your computer and use it in GitHub Desktop.
How to set up xdebug with mamp and PHP Storm (drupal 8 site) (MacOS)
  1. Install the xdebug chrome extension and turn it on by clicking on it and clicking on debug: https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc

  2. Type the following into your terminal (This will return the location of the php ini file being used, once you have the path you will need to open the file - also note the php version being used, this will be important later):

php --ini
  1. Find xdebug in the php.ini file and add the following (if the zend_extension line has a semi colon ";" remove it):
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
xdebug.max_nesting_level=1000
xdebug.remote_port=9001
xdebug.idekey=PHPSTORM
  1. Restart your mamp server

  2. In phpstorm with your project open do the following:

  3. Go to Phpstorm -> Preferences (cmd + ,)

  4. Go to Languages and Frameworks -> then click on PHP

  5. Create a new interpreter by Clicking the 3 dots... next to CLI interpreter -> and then click the plus button (Choose other local from the options)

  6. You can name it anything (PHP [VERSION_IN_USE]) is recommended

  7. Choose "PHP Executable" path this will look something like the following: /Applications/MAMP/bin/php/php[VERSION_IN_USE]/bin/php

  8. You will know it has worked if Debugger has Xdebug [VERSION_NUM] and the php version is being shown next to a blue i. Once done, click Apply and the Ok.

  9. Once this is done you will return to the preferences dialogue, once here search "debug" in the search box and there should be an option to click Debug under: Languages and Frameworks -> PHP -> Debug

  10. Under Xdebug change the "Debug Port" to 9001 -> Once done, click Apply and the Ok

  11. Now open your index.php file and add some breakpoints on any of the lines

  12. You will need to make sure that your phpstorm is listening for debug connections you can do this by going to: Run -> then click on Start listening for php debug connections or simply click the phone icon with a red circle and bug on it in the top right of phpstorm

  13. Go to your web browser where your site is being hosted locally (for me this is localhost:8888) and refresh the page, if all steps have worked, an "Incoming connection from xdebug" digalog should open in php storm you simply need to click "Accept" you will be able to use xdebug on your site. If this does not work you may need to restart your MAC and try this step again. When you do ensure the connection is still on before trying again (previous step)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment