Skip to content

Xdebug

Turn Xdebug on for a PHP version on the Runtimes screen. The first time, DevKit builds Xdebug for that version, which takes a minute.

With Xdebug on, DevKit starts a second PHP pool for that version with Xdebug loaded. Requests go to it only when they ask for a debug session; every other request keeps using the normal pool, so your sites stay fast.

A request asks for a session with any of these:

  • an XDEBUG_SESSION or XDEBUG_TRIGGER cookie (set by the Xdebug browser extension, or by your editor)
  • XDEBUG_SESSION_START, XDEBUG_TRIGGER or XDEBUG_PROFILE in the query string

Xdebug connects to your editor on 127.0.0.1:9003. In PhpStorm, start listening for debug connections; in VS Code, start a “Listen for Xdebug” launch configuration.

Each session starts in DevKit’s small prepend file before your code. PhpStorm’s Force break at first line when a script is outside the project (Settings › PHP › Debug) would stop there; turn it off.

Runtimes › Xdebug settings changes the port and the modes (debug and develop by default; add coverage, profile or trace when you need them).

With Also for Artisan, queue workers and tests DevKit runs on, devkit php and the processes DevKit runs load Xdebug too. They connect to your editor only when started with XDEBUG_SESSION=1:

Terminal window
XDEBUG_SESSION=1 devkit php artisan my:command