2. Xdebug

https://xdebug.org/

2.1. Install

$ sudo apt install php-xdebug

Show php version info to see Xdebug is enabled:

$ php -v
PHP 8.2.29 (cli) (built: Jul  3 2025 16:16:05) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.29, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.29, Copyright (c), by Zend Technologies
    with Xdebug v3.2.0, Copyright (c) 2002-2022, by Derick Rethans

2.2. Configure

Edit file /etc/php/8.2/apache2/conf.d/20-xdebug.ini:

 zend_extension=xdebug.so
+
+[xdebug]
+xdebug.mode=debug
+xdebug.start_with_request=yes
+xdebug.client_host=172.16.109.1
+xdebug.client_port=9003
+xdebug.log=/var/log/xdebug.log

Make sure the log file can be accessed by the apache server:

$ sudo touch /var/log/xdebug.log
$ sudo chown www-data:www-data /var/log/xdebug.log

In vscode launch.json:

{
    "name": "Listen for Xdebug",
    "type": "php",
    "request": "launch",
    "port": 9003,
    "pathMappings": {
        "/mnt/hgfs": "/Users/xxxx"
    }
}