We will setup debugging using xdebug with PHP inside of visual studio code.
1) install php-xdebug:
sudo apt install php-xdebug
2) inside of php.ini at the end of the file set:
xdebug.start_with_request = yes
xdebug.mode = debug
xdebug.discover_client_host = false
3) install php debug extension in VSCODE and set the port of the vscode php debug extension to 9003.
Now you can press F5 and start debugging.
Alternatively you can install xdebug using pecl.
The setup is valid for Ubuntu both on bare-metal as well as under Windows 10 with WSL.