Firstly, I want to inform you that English is not my first language, and I apologize for my imperfect English.
I configured Xdebug to debug in VSCode. Three icons of Xdebug are inactive (Step into Step out, Step Over).
The Xdebug configuration seems good:
php -v
gives:
gerard@gerard-ThinkCentre-M700:~$ php -v
PHP 8.1.2-1ubuntu2.14 (cli) (built: Aug 18 2023 11:41:11) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2-1ubuntu2.14, Copyright (c), by Zend Technologies
with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans
My Xdebug configuration (/etc/php/8.1/mods-available/xdebug.ini
) **:
zend_extension=xdebug.so
xdebug.mode = develop, debug
xdebug.start_with_request = yes
xdebug.log = /tmp/xdebug.log
xdebug.client_host = localhost
xdebug.client_port = 9003
And this is the xdebug.log
(the message is also present in Xdebug_info.php):
[10694] Log opened at 2024-03-15 08:52:39.285551
[10694] [Step Debug] INFO: Connecting to configured address/port: localhost:9003.
[10694] [Step Debug] WARN: Creating socket for 'localhost:9003', poll success, but error: Operation now in progress (29).
[10694] [Step Debug] ERR: Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_p>
[10694] Log closed at 2024-03-15 08:52:39.287093
[10696] Log opened at 2024-03-15 08:52:39.308197
[10696] [Step Debug] INFO: Connecting to configured address/port: localhost:9003.
[10696] [Step Debug] WARN: Creating socket for 'localhost:9003', poll success, but error: Operation now in progress (29).
[10696] [Step Debug] ERR: Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_p>
[10696] Log closed at 2024-03-15 08:52:39.308848
[10852] Log opened at 2024-03-15 08:52:58.522332
[10852] [Step Debug] INFO: Connecting to configured address/port: localhost:9003.
[10852] [Step Debug] WARN: Creating socket for 'localhost:9003', poll success, but error: Operation now in progress (29).
[10852] [Step Debug] ERR: Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_p>
[10852] Log closed at 2024-03-15 08:52:58.524340
[10853] Log opened at 2024-03-15 08:52:58.549547
[10853] [Step Debug] INFO: Connecting to configured address/port: localhost:9003.
[10853] [Step Debug] WARN: Creating socket for 'localhost:9003', poll success, but error: Operation now in progress (29).
[10853] [Step Debug] ERR: Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_p>
[10853] Log closed at 2024-03-15 08:52:58.550293
" netstat -an | grep 9003" give when debugger is active:
gerard@gerard-ThinkCentre-M700:~$ netstat -an | grep 9003
tcp6 0 0 :::9003 :::* LISTEN
launch.json
of VSCode:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003
}
]
}
Xdebug with VSCode works in two ways:
1 - with a CLI session (without server and with no launch.json: configuration file):
2 - with a local server web with a launch.json:
3 -With the PHP web server:
php -S localhost:8082
The port number 8082 can be changed.
You can read what I said here: https://doc.ubuntu-fr.org/visual_studio_code#serveurs_web_internes (partie 2.3)