DEV Community

Cover image for XDebug, VScode, ubuntu
Mohammad Reza
Mohammad Reza

Posted on • Updated on

XDebug, VScode, ubuntu

For installing the XDebug in ubuntu and use it from VScode follow these steps

1.Step one

Run this command

sudo apt install php-xdebug
Enter fullscreen mode Exit fullscreen mode

2.Step two

Run this command

sudo nano /etc/php/7.4/mods-available/xdebug.ini
Enter fullscreen mode Exit fullscreen mode

Then go to the end of the file and add these lines

[xdebug]
zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9000

Enter fullscreen mode Exit fullscreen mode

For finding the path of the xdebug (/usr/lib/php/20190902/xdebug.so)
you can run this command

locate xdebug.so
Enter fullscreen mode Exit fullscreen mode

3.Step three

Open the configuration file of Xdebug by clicking ‘Add Configuration…’ from the menu Run and set the necessary configuration according to the xdebug.ini file.
It will become sth like this

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

Done
Alt Text

Top comments (2)

Collapse
 
theplacid profile image
theplacid

thanks alot!

Collapse
 
azibom profile image
Mohammad Reza

De rien! :-)