How to enable Xdebug v-3.3.2 in Visual Studio Code
Viktor Le
Posted on April 21, 2024
Today, I upgrade my project to new laravel version, v-10, and want to install xdebug for development a bit easier. I am around to search on the internet how to install xdebug in Laravel.
Firstly, I install xdebug.so in my local machine. Then, I check if it is installed already by the following command
$ php -m | grep xdebug
xdebug
Yes, it shows xdebug. In case non line shown, then Xdebug needs installed by the following prompt on MacOS, or follow the offical document - https://xdebug.org/docs/install
pecl install xdebug
Secondly, I search on the internet that all the posts have been related to xdebug instruct me to find php.ini and add new lines in EOF.
[xdebug]
xdebug.remote_enable=1
xdebug.remote_autostart=1
Thirdly, I create a launch.json file in VS code by clicking bug icon, then I select PHP (Xdebug)
Bump, snippet json file is generated automatically
{
// 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
}
]
}
Finally, I start Xdebug by clicking on Listen for Xdebug
In the result, no breakpoint is hit. Oops!
I try to search how and find that, the section in php.ini is out-up-dated. new Xdebug version uses another one to enable the mode, instead that, use it
[xdebug]
xdebug.mode=debug
xdebug.start_with_request=1
I try to turn on Xdebug mode again. Wow, one of breakpoints is hit.
Hope my post can help you navigate the situation when installing Xdebug v-3.3.2 in Visual Studio Code
Posted on April 21, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.