I use Drupal VM with php5-fpm and it uses port 9000 so I just set my debug ports to 9001.
-
Set the debug port to 9001 in PHPStorm
-
Create a new server in PHPStorm:
- Preferences >> Languages & Framworks >> Servers
- Add a Name: and Host: e.g., mysite.dev (for both)
- Click the checkbox: Use path mappings...
- I always map my local DRUPAL_ROOT to my VM DRUPAL_ROOT
-
Now ssh into the VM but we are going to forward a port:
ssh -R 9001:localhost:9001 drupalvm
- The
drupalvm
in the command above refers to an entry in my~/.ssh/config
file. - This is what that looks like:
Host drupalvm HostName 127.0.0.1 User vagrant Port 2222 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /opt/drupal-vm/.vagrant.d/insecure_private_key IdentitiesOnly yes LogLevel FATAL ForwardAgent yes
- On the VM run:
export XDEBUG_CONFIG="idekey=PHPSTORM remote_host=127.0.0.1 remote_port=9001” && export PHP_IDE_CONFIG=“serverName=mysite.dev"
- In PHPStorm right click on External Libraries and select Configure PHP Includes path...
- Click the + button (bottom left corner)
- Locate the path to your local copy of Drush e.g.,
/Users/scott/.composer/vendor/drush/drush
- Click Apply
- Go back to where you added your server and add a path mapping from you local copy to where Drush is in the VM
Set a breakpoint on the first line of drush.php
in the External Libraries
BOOM!