- 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...)
![step1](https://camo.githubusercontent.com/6ba4d0396efe68a94cb46d78b11199093d61cdf5da117fd12c48c0a4937aba47/687474703a2f2f692e696d6775722e636f6d2f307a694c6735702e706e67)
![step2](https://camo.githubusercontent.com/196d3f64751837102fe78c620b43cda298ee760f1c168e54bee4c21dab34f1a4/687474703a2f2f692e696d6775722e636f6d2f5446344e7167332e706e67)
- 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.