Remote debugging with XDebug

Tom Adam

How are you debugging?

  • XDebug
  • var_dump, echo and die
  • Enhanced var_dump
  • Logging
  • Unit testing

Interactive Debugging

  • Variable editing
  • Stack trace
  • Conditional breakpoints
  • Remote debugging
  • Execution line alteration

XDebug

  • Supports up to PHP 7.1
  • Easily installed
  • Lots of useful features
  • Supported by most IDE's

Demo

  • XDebug client, IDE server
  • Enable module
  • xdebug.remote_enable = 1
  • Use browser plugin

Config

Chrome: https://chrome.google.com/webstore/detail/xdebug-helper

  • export XDEBUG_CONFIG="idekey=session_name"
  • xdebug.idekey="abc", xdebug.remote_autostart=1

Web

CLI

  • xdebug.remote_host = host ip
  • For web: xdebug.remote_callback = 1
  • Check firewall!

Config

Vagrant

  • XDebug makes things slow
  • Performance issue for CLI apps
  • Tests 3x faster

Gotchas

CLI Apps

Fix

  • Disable on CLI
  • Enable selectively using alias
  • alias php='php -dzend_extension=xdebug.so'
  • Long FastCGI timeout

More Gotchas

FPM

Breakpoint positions

  • Some won't trigger
  • Multi-line statements are usual culprit

Max nesting level

  • Default too low before current version
  • Set to ~250

?

Remote debugging with XDebug

By tomadam

Remote debugging with XDebug

  • 1,245