Installing Xdebug

Installing and Configuring Xdebug

Xdebug 16,266 (github.com/xdebug/xdebug (https://github.com/xdebug/xdebug 3,416 ), by Derick Rethans) hooks the engine. sudo apt install php8.5-xdebug installs 3.5.0 on Ubuntu 26.04 225 ; pecl install xdebug builds the newest, 3.5.3 of 8 June 2026. xdebug.mode picks the features, comma-separated: develop (richer var_dump(), error traces), debug (Step Debugging from an Editor), profile and trace (Profiling with Xdebug), coverage (Code Coverage) or off. Never load it in production: it slows every request.

xdebug.ini for a development machinePHP
zend_extension=xdebug
xdebug.mode=develop,debug
xdebug.start_with_request=trigger   ; only when the request asks (4.21.4)
xdebug.client_host=127.0.0.1        ; where the editor listens; xdebug://gateway in Docker
xdebug.client_port=9003             ; Xdebug 2 used 9000
xdebug.log=/tmp/xdebug.log

php --ri xdebug shows the active settings. To load it for one command only, as every example here does, pass -d. Develop mode shows why it stays off by default: it rewrites var_dump() output.

Develop mode for one command onlyShell
php -d zend_extension=xdebug -d xdebug.mode=develop \
  -r 'var_dump(["sku" => "BK-SQL-02", "stock" => 0]);'
Output
Command line code:1:
array(2) {
  'sku' =>
  string(9) "BK-SQL-02"
  'stock' =>
  int(0)
}