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
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-08-31 11:00:00 +0000
Seen: 12 times
Last updated: Jan 30
How can a HTTP header be inserted in WordPress?
How can data be stored in a data attribute and utilized through Ajax?
How can an array be passed using typo3 flexform xml and itemsProcConfig?
Does JSON encode fail to retrieve data from the database?
Can the GS1 128 barcode decoder in PHP or Jquery be utilized?
In PHP, what is the method for finding encrypted data using the "like" operator?
What is the method to pass a variable from PHP back to JavaScript?
Why do PHP variable variables display unexpected behavior when used with arrays?