To debug PHP tests in Ubuntu (assuming PHP 8.2 is the default) with Visual Studio Code:
Install Xdebug:
sudo apt install php8.2-dev sudo pecl install xdebug
Enable Xdebug:
php --ini # verify the INI file location sudo su echo 'zend_extension=/usr/lib/php/20220829/xdebug.so' >> /etc/php/8.2/cli/conf.d/99-xdebug.ini
Verify that it is enabled:
$ php --version PHP 8.2.16 (cli) (built: Mar 7 2024 08:55:56) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.16, Copyright (c) Zend Technologies with Zend OPcache v8.2.16, Copyright (c), by Zend Technologies with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans
Activate debugging by adding the following lines to /etc/php/8.2/cli/conf.d/99-xdebug.ini:
/etc/php/8.2/cli/conf.d/99-xdebug.ini
xdebug.mode = debug xdebug.start_with_request = yes
Open VS Code and install the PHP Debug extension.
Activate debugging according to instructions on the extension site.
Test debugging.
composer test
There was an error while loading. Please reload this page.