How I installed XDebug on Fedora OS and configured it for VSCode

How I installed XDebug on Fedora OS and configured it for VSCode

Hi there dev,

It is no gain saying that debugging is a huge part of coding. You probably spend more time fixing bugs than you do writing the actual code. I currently write PHP for my server side development, and had to install XDebug to help out with debugging my code.

First of, I will like to say a big thank you to the developers who have made this great tool free and open source. So please support XDebug. For the culture.

I know there are lots of resources online that already explain this process, but most i have seen could not comprehensively walk me through. So, here is what i did.

I had PHP, Laravel and Vscode already installed. According to the docs at linuxconfig.org/how-to-install-xdebug-on-re.., i needed to install php-devel and php-pear. So i did

sudo dnf install php-devel php-pear

As usual, the sudo command would prompt for Admin password whenever you use it. So I typed it in and it installed all necessary stuff for me.

Next, I install XDebug using PECL using the command

pecl install xdebug

if that doesn't work try adding sudo, like,

sudo pecl install xdebug

That should work fine.

Next, I had to configure PHP to use XDebug. To do this, I created a configuration file for XDebug with the /etc/php.d with the name 30-xdebug.ini, this command worked it all out.

touch /etc/php.d/30-xdebug.ini

Next, you need to put in the configuration, so i did,

nano ~/etc/php.d/30-xdebug.ini

and pasted the following configurations,

zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.remote_log="/tmp/xdebug.log"
xdebug.profiler_enable = 1
xdebug.remote_enable=on
xdebug.remote_port=9000
xdebug.remote_autostart=0
xdebug.remote_connect_back=on
xdebug.idekey=editor-xdebug

Used CTRL+O to write out of nano and CTRL+X to exit. Then I restarted my computer.

After installing xdebug, I needed to use it in VSCode, so I already installed PHP debug by Felix Becker. Great tool. With that I could see this when I click the debug tab

debug.png

And then I decided to do some configuration changes in VSCode by clicking on the debug tab and then 'Add configurations' as shown below

debugq.png

This opened the 'launch.json' file

debug2.png

I didn't need to change anything, the settings worked just fine.

Finally, I had to edit the .bashrc file located at ~/.bashrc to input the Xdebug config as mentioned at tighten.co/blog/configure-vscode-to-debug-p.. I did this using the command,

sudo nano ~/.bashrc

Then I entered this at the end of the file

export XDEBUG_CONFIG="idekey=VSCODE"

like this,

debbbbbbb.png

Used CTRL+O to write out of nano and CTRL+X to exit.

Then you can run

source ~/.bashrc

And that was it!

Debug on my friends!