Xdebug is an extension for PHP, and provides a range of features to improve the PHP development experience.
What Xdebug is isn’t that complicated. But making sure we know how it works, at least at a high level, is important so we understand the tool as we use it. It also makes it easier to understand the setup process if we know how Xdebug works.
Step 1: Prerequisites
Step 2: Update Your Machine
This will help system download any missing package updates. If any of the packages needs to be upgraded then run apt upgrade command as well.
Step 3: Install PHP Xdebug
In the next step, you can install PHP Xdebug package by using apt install php-xdebug command as shown below. This will download the package along with all its dependencies from default Ubuntu Repo.
Ubuntu (18.04 LTS/Bionic, 20.04 LTS/Focal):
Ubuntu (Ondřej Surý's PPA):
Then check if Xdebug is installed by typing php -v
Then open the file with whatever editor is convenient and make sure it includes the following
Add the following code into it:
zend_extension=xdebug.so
xdebug.mode=develope,debug
xdebug.start_with_request=yes
Save and close :wq
How you install Xdebug depends on your system. There are the following possibilities
Launch Visual Studio Code and, if the Xdebug extension has not yet been installed, then navigate to the extensions panel, search for PHP Debug and then install and enable the plugin.. It should look something like the image above:
Then to debug on Visual Studio Code, click on Run and Debug then, in the top of the panel, choose Listen for Xdebug and click the Play icon. This will bring up the set of controls for stopping, pausing, starting, stepping over, and stepping into code.
Xdebug is now properly installed, configured, and running on your machine.
From here, starting the Xdebug Helper extension and starting Xdebug within Visual Studio Code will give you everything you need to start debugging your code.
I am currently working on a shopify website and did not want to use a shopify plugin so I set out to code my own! Leaving a little bit of instructions here for anyone else who would like to use this as well. Happy coding beautiful people!
Launch Visual Studio Code and create a new file called index.php and copy and paste the following code below.
This script counts from one to a hundred
In order to step debug the code create a break point on margin line three
Select the Run and Debug tab and click Run and Debug
And the following results must display
Advancing the script:
I hope this has been a good introduction to how powerful and valuable using a debugger like Xdebug is for your development workflow, as well as a possible alternative if you find it too complex.
We have the best people for your next big project
Johannesburg
Gauteng, South Africa
Nelspruit
Mpumalanga, South Africa
Port Elizabeth
Eastern Cape, South Africa
Lagos
Nigeria
Your request has been successfully sent
Oops! currently we dont have any open vacancies.