Skip to content

Instantly share code, notes, and snippets.

@weitzman
Created June 6, 2017 20:29
Show Gist options
  • Save weitzman/3157b7f56becf5bfd8c9959be031b171 to your computer and use it in GitHub Desktop.
Save weitzman/3157b7f56becf5bfd8c9959be031b171 to your computer and use it in GitHub Desktop.
Outside the VM
In PHPStorm,
Run => Start Listening for PHP Connections
Run => Break at first line in PHP scripts
Inside the VM
Navigate to docroot and run:
XDEBUG_CONFIG="idekey=phpstorm remote_host=`netstat -rn | grep "^0.0.0.0 " | tr -s ' ' | cut -d " " -f2`" php -dzend_extension=xdebug.so -d xdebug.remote_enable=1 ../vendor/bin/drush st
Sets the XDEBUG_CONFIG environment variable. The value has two components:
idekey - not clear if this is needed
remote_host - The value is the IP address of the host machine. This tells the VM's PHP how to connect back to your PHPStorm. The value is dynamically figured out by netstat. See this Stack Overflow post.
Calls php with options that load xdebug extension (already present in the VM) and enables xdebug's remote debugging.
Pass the drush script as first argument to php. In this example, we run Drush's st command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment