Xdebug is PHP developer best tool for development. As a php developer it is hard to write code without using it. Sometimes its configurations problem to setup it with vagrant
sudo nano /etc/php/{YOUR PHP VERSION}/mods-available/xdebug.ini
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.start_upon_error = true
xdebug.discover_client_host=false
xdebug.client_host=192.168.10.1 # your host ip (Not the vagrant ip address)
xdebug.client_port=9003 # the debugging port from the client
xdebug.max_nesting_level = 250
xdebug.idekey=VSCODE # if you are using php `PHPSTORM`
xdebug.log=/tmp/xdebug.log
Restart the PHP service
sudo service php{YOUR PHP VERSION}-fpm restart
create a launch.json file to configure xdebug for 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": "PHP",
"type": "php",
"request": "launch",
"pathMappings": {
"PATH TO THE PROHECT INSIDE YOUR VAGRANT MACHINE": "${workspaceFolder}",
},
"port": 9003,
"log": true
},
]
}