Skip to content

Instantly share code, notes, and snippets.

@scottalan
Created March 1, 2016 16:10
Show Gist options
  • Save scottalan/badc7308da1d31599db5 to your computer and use it in GitHub Desktop.
Save scottalan/badc7308da1d31599db5 to your computer and use it in GitHub Desktop.
Remote Debugging - PHPStorm

Remote Debugging - PHPStorm

PHPStorm Settings

Preferences >> Languages & Frameworks >> PHP >> Servers

Add a server:

Name: mydomain.dev
Host: mydomain.dev
Check: Use path mappings and define the absolute path on the server for webroot

Tunnel into the remote machine

This assumes you are using port 9000

From your local machine:

ssh -R 9000:localhost:9000 [SSH_CONFIG]

On the remote machine:

export XDEBUG_CONFIG="idekey=PHPSTORM remote_host=127.0.0.1 remote_port=9000”

Use the Name: you setup in PHPStorm

export PHP_IDE_CONFIG=“serverName=mydomain.com"

Debugging

Testing drush ev. Set a breakpoint in a function like menu_get_item()

On the remote machine:

drush ev 'return menu_get_item();'

Now let's debug Drush:

Add an alias on the Remote machine:

function bugon() {
  export XDEBUG_CONFIG="idekey=PHPSTORM remote_host=127.0.0.1 remote_port=9000";
  export PHP_IDE_CONFIG='serverName='"$@";
}

function bugoff() {
  unset XDEBUG_CONFIG && unset PHP_IDE_CONFIG;
}

Now you can enable:

bugon mydomain.com

and disable:

bugoff

Open you local version of Drush. Mine is at:

/Users/shenry/.composer/vendor/drush/drush

Add a server configuration with path mappings. I just used the same mydomain.dev Map the local path to the path on the Remote machine:

My remote path was:

/usr/local/share/drush

In PHPStorm open:

commands/core/help.drush.inc

Set a breakpoint in:

drush_show_help()

On the remote machine run:

drush -h

Score!!

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