How to debug PHP in Visual Studio Code (Simple steps)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there this is your best friend in programming serial cheat and today we are going to talk about how to set up PHP debugging in Visual Studio code now debugging can be very helpful to make your programming life easier and with it you can stretch through the code you can see what's going on and check out the values of the variables and it is very easy using visual studio code and PHP I've got my debugger set up already and when I hit the play button I can then load up my file and if I refresh it the debugger will be hit and then I can strap through the code I can see what's going on I can check the values of the variables and fix the code as I need to set this up for yourself it's an easy process the first thing you need is to install zamp now Visual Studio code debugging with PHP works on Zam so you will need the zamp server it's actually a collection of various things you get Apache server you get MySQL these are the two services that I usually need Apache and Maya skill and I've got a separate installation of MySQL so I'm not running it yet you can get Zam free online just go to google.com and look for Zam it'll take you to the Zam website you can download the version that's right for you and install it and that will give you access to the xampp server of course you will need PHP and PHP is installed alongside Zam so xampp actually gives you Apache mariadb PHP and perd next thing you need to do is download and install X debug and we will be using the wizard for it I will show you exactly how that works so what you need to do is go to your browser and then open localhost that's where the Zam server usually is running and you will see the jam dashboard and there is the link to PHP info over here click on it and this is the entire PHP info file that has a lot of information about your PHP installation next thing we need to do is type X debug in Google and it will take you to the X debug website which is xdebug.org click on install and it will have several installation options we're not going to use any of these just search for Wizard foreign to the wizard click on it and it'll give you a box where you need to put in some information to find the right X debug file for you now what you need to do is go back to the PHP info screen click on view page Source then copy the entire text bring it back to the wizard paste it all over here then analyze your PHP info and the installation wizard will actually tell you exactly what PHP file you need and you can see over here it's got some helpful instructions too the first thing download PHP X debug file and I've done that next you need to move it to the place where you have the PHP EXT folder in Zam this is where zamp is installed on my computer for example and you will need to rename the file to phpx debug and I have done that already so if you can find it over here it's right over here the file has been copied and renamed so do that on your computer too next thing you need to change something in PHP dot any InStyle of the PHP installation so we'll go up go up one folder then we'll look for PHP dot any and what you need to change is three things you need to change you need to enter this line Zen extension X debug but apart from that you also need to set up X debug correctly and to do that you also need to paste this right below your Zend extension equals to X debug and that's it for php.ini you're done over here the next step is enter the PHP exe path in the settings Json of visual studio so to do that what we're going to do is we will just copy the path from here like this and then we're going to go to visual studio click over here and type settings.json when you find it if you all right so before this you need to do one more step and that is to go to extensions and look for PHP debug in the extensions list now if you don't have this installed already you will need to click on it and then install it I already have it installed so I'm not gonna mess with it now but after that load up the settings.json file and then you will have a setting for PHP debug executable path and this is where you need to put in your entire PHP path so I I copied over the path from here paste it like this and then also write php.exe because you need the entire executable path and not just the folder name of course you will need to put double slashes over here to make this work save it then restart your Apache installation like this and all right it's running now and then when you go to index.php put your breakpoints as usual come back to visual come back to the debugger and you have two more three modes for debugger first is listen to X debug then you have launch currently open script which will just run this without a browser and then you can also launch the built-in web server now I do like to use Apache so what I'm going to do is listen for X debug and then hit the play button now the debugger is running now all I need to do to actually debug this is go to my page and just refresh so you can see the breakpoint is hit and I can step through the code so this is how easy it is to set up the PHP debugger in Visual Studio I hope you do that too and make your programming better this is siljit signing off
Info
Channel: coderJeet
Views: 47,776
Rating: undefined out of 5
Keywords: php programming, learn php, php debugging, debug php, programming, coding in php, software development, php coding, php software programming, php debugger, how to debug php, xdebug
Id: 8ka_Efpl21Y
Channel Id: undefined
Length: 5min 58sec (358 seconds)
Published: Mon May 01 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.