PHP Debugging VSCode MAC OS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone in this video I'm going to show you how to install the debugger for your PHP code this tutorial is going to assume that you are a Mac User and that you are operating with map and also you wish to enable X debugger for your PHP code the first step you are required to do is essentially determine which PHP version your map software is running in order to determine this all you are required to do is go into the window where you ran your map installation and on that window you will see at the bottom the PHP version that your map installation runs so for me as an example I'm running 7.4.21 Step 2 is to edit the two configuration files in order to enable X debugger so as you can see right here the two configuration files that we need to edit are these two PHP dot any files I'll put their respective directories in the description box at the bottom but essentially you'll find an under your applications folder map conf PHP version you run php.in go ahead and open the two php.infiles as I did right here and now we can go ahead and enable X debugger so to do that just scroll all the way to the bottom of the file you'll see a section called X debug so what you want to do is essentially uncomment this Z extension part by deleting the semicolon at the beginning of it then you will need to copy paste this code right here put into this YouTube's description box once you're done with the first file go ahead to the second php.infile and do the exact same thing so after editing the PHP dot any files saving what you need to do now is essentially restart your map installation so that's pretty simple just stop it right here and restart it okay now what you need to do is essentially go to vs code and install an extension that is called PHP debug so go ahead and install it enable it and you're good to go so before we proceed just note that X debugger is registered under the port 9000. the next step is essentially to run it under vs code so what I did was I went under the Run tab at the top right here click it then click Start debugging I already did it but essentially what happens is vs code will request to you if you want to essentially create this launch.json file right here and what you need to do is just click yes once you open launch.json file you need the port numbers to match what you set up in the php.ini files earlier which was 9000 so go ahead and edit the first port to 9000 and then scroll a bit and you'll find the second Port where you are required to change this to 9000 also in order to debug properly and have your errors logged out in your console on your front end in the launch.json file under configurations add this line of code which specifies that the external console is set to True save your changes then try to rerun your debugger again Run start debugging click it then vs code should tell you that you don't have a PHP executable so in order to set up a PHP executable what you need to do is either go under your settings and then under this PHP debug executable path click edit in settings.json it should open up this settings file and under the settings file what you need to do is scroll to the bottom and tell vs code which PHP software you are going to use in order to debug your code my PHP executable file is located under applications map bin PHP PHP version number bin PHP yours will be located somewhere similarly and so I will put a example directory in the description box for you to find yours easily also you would want to add the same PHP executable that you did previously in the debug mode for the validate mode and the way to do that is to Simply add this line of code right here same as the used in the PHP executable to debug now that we have everything set up properly go ahead and rerun vs code to make sure everything is in place then go under run again start debugging then go under the PHP script that you want to debug once your breakpoints are placed we can go ahead and Trigger them so I just triggered my first breakpoint and if you never used a debugger before this panel right here essentially helps you manipulate the breakpoint and essentially move it so as you can see here my first break point is that this method determinator command and so there's nothing special to do here so I'm just gonna move to the next break point by clicking display icon so now we move to the next break point which is at this data decode or Json decode command here and so a debug console what you can do is write the variable that you wish to visualize and hit enter and the debug console will show you what this variable contains or what I like to do is put all my variables under this watch section right here and my debugger will output their values in real time as the debugger pointer changes locality so with all that being said I hope you gain value from this video please do consider subscribing liking and commenting if you have any technical issues for example I will try to respond to your comments if you want to go through a written format of this tutorial I put in the description the URL well toward my blog post where I essentially go through everything I just talked about in this tutorial also if you require web development web design AI automation SEO Services you can go ahead to earn answers.com which will be in the description also and you can submit your email in the home page and I'll come back to you and we can book a call to further our discussions and to further your plan thank you very much thank you
Info
Channel: Earnanswers
Views: 1,155
Rating: undefined out of 5
Keywords:
Id: AeOZLNBPrlM
Channel Id: undefined
Length: 7min 26sec (446 seconds)
Published: Mon Aug 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.