1 | initial version |
To use Xdebug with VSCode for Laravel on Sail and WSL2, follow these steps:
sudo apt-get install php-xdebug
php.ini
file:[xdebug]
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
launch.json
file with the following configuration:"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"log": true,
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
},
"port": 9003,
"hostname": "127.0.0.1",
"serverSourceRoot": "/var/www/html/",
"localSourceRoot": "${workspaceFolder}/",
"stopOnEntry": false
}
]
docker-compose.yml
file:services:
laravel.test:
environment:
XDEBUG_MODE: "debug"
XDEBUG_CONFIG: "client_host=127.0.0.1 client_port=9003"
Listen for Xdebug
configuration in VSCode and placing breakpoints in your code.Note: Ensure that your WSL2 firewall allows connections through port 9003 by running the command below:
sudo ufw allow 9003