XAMPP - XDebug Setup for PHP 8

Daniel Opitz
Daniel Opitz
03 Dec 2020

Requirements

Setup

[XDebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.start_with_request=trigger

PhpStorm

Netbeans

Visual Studio Code

Postman

Add XDEBUG_SESSION_START=PHPSTORM as query parameter to the url, e.g.

Starting the debugger from the console

Enter cmd:

set XDEBUG_CONFIG="idekey=xdebug"
php test.php

Known Issues

Can’t locate API module structure ‘php8_module’

Read more: https://community.apachefriends.org/f/viewtopic.php?f=16&t=80105#p270731

Xdebug: Step Debug Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(

Change xdebug.start_with_request=yes to xdebug.start_with_request=trigger

Warning: XDEBUG_MODE=coverage or xdebug.mode=coverage has to be set

If you change the php.ini setting from xdebug.mode=debug to xdebug.mode=coverage it should work. But then it is not possible to trigger the debugger in the browser for PhpStorm.

Instead, you can run phpunit from the console with this command:

php -d xdebug.mode=coverage -r "require 'vendor/bin/phpunit';" -- --configuration phpunit.xml --do-not-cache-result --coverage-clover build/logs/clover.xml --coverage-html build/coverage

This is how you can use the same command in a composer.json script:

"test:coverage": "php -d xdebug.mode=coverage -r \"require 'vendor/bin/phpunit';\" -- --configuration phpunit.xml --do-not-cache-result --coverage-clover build/logs/clover.xml --coverage-html build/coverage"

The php -d command line option defines the php.ini entry xdebug.mode with value coverage.

Then it starts the phpunit php script and passes the console arguments after the additional -- separator. This works on Linux and on Windows.