- SSH to your machine like this:
ssh -R 9000:localhost:9000 your.remote.machine
- Ensure you have Xdebug installed and configured with
xdebug.remote_enable=1
- Add this snippet to your
.bash_profile
or similar shell init script:
# XDebug
function xdebug-start {
xdebug_site=$1
xdebug_host=$2
xdebug_port=$3
xdebug_idekey=$4
if [[ -z $xdebug_site ]] then
xdebug_site="site.dev"
fi
if [[ -z $xdebug_host ]] then
xdebug_host="127.0.0.1"
fi
if [[ -z $xdebug_port ]] then
xdebug_port="9000"
fi
if [[ -z $xdebug_idekey ]] then
xdebug_idekey="PHPSTORM"
fi
export PHP_IDE_CONFIG="serverName=$xdebug_site"
export XDEBUG_CONFIG="remote_host=$xdebug_host remote_port=$xdebug_port idekey=$xdebug_idekey"
}
alias xdebug-stop="unset XDEBUG_CONFIG && unset PHP_IDE_CONFIG"
- Set your debug config in IntelliJ naming it to site.dev and mapping your local directory to your remote directory (Menu Run > Debug...)


- Start listening to debug connections clicking in the menu Run > Start listening...
- Set a breakpoint in your code in IntelliJ
- Run in the SSH terminal:
xdebug-start
- Run your tests in the SSH terminal (in fact, it can work to any CLI php script also)
Change the ifs to:
for compatibility issues.