Using XDebug with a PHP CLI Script That Forks Children

Problem:

Stepping through a PHP CLI script that forks processes (with pcntl_fork()) causes Eclipse debugger to hang.

Solution:

Xdebug config:

xdebug.remote_enable = 1

; IP of the machine where the debug client is running, 
; such as the vagrant host machine.
xdebug.remote_host='10.0.2.2'

xdebug.remote_autostart = 1
; "jit" = connect to client only on errors and xdebug_break().
xdebug.remote_mode = jit
xdebug.show_local_vars = 1

Eclipse config:

Preferences -> PHP -> Debug -> Installed Debuggers -> XDebug:

Accept remote session (JIT) = Prompt

Add new comment