DEV Community

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

Posted on • Edited on

12 2

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

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (2)

Collapse
 
theplacid profile image
theplacid

thanks alot!

Collapse
 
azibom profile image
Mohammad Reza

De rien! :-)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay