Installing Xdebug on macOS, Valet, & VSCode - with Derick Rethans

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

In case anybody watches it, can you do everybody else a favor and tell whether this is a video with 55 minutes of small-talk and laughing about a tweet and the reactions and 10 minutes showing how easy it is setting up Xdebug - or the other way around?

👍︎︎ 4 👤︎︎ u/muchgibberish 📅︎︎ Jun 24 2020 🗫︎ replies

The Derick guy I see every time I do php -v! Man. That guy IS php!

👍︎︎ 4 👤︎︎ u/dusty_bottom 📅︎︎ Jun 24 2020 🗫︎ replies
Captions
so Derek thank you so much for joining me thanks for putting up my bike and you look 10 minutes in we're good which means if we'd showed up three months earlier like you said we wouldn't find thanks for you doing with all this so Derek can you introduce yourself I know you're the XD bug guy but could you just say hi to everybody and tell them a little bit about what XD bug is and who you are and where you're from and everything hi I'm Derek I live in the UK I'm originally from the Netherlands I've been doing PHP things for a long long time longer than I can count probably over 20 years and I wrote X debug a debugging tool that we're going to have a look at today here as well as peach peas daytime extent and back in the olden days I fixed or tried to reproduce lots of bugs in PHP too right at the moment I'm a Birkhoff time onyx neba can have my all the time various contracts okay an XD bug you recently put out something was at patreon I think where you were saying hey I want to get this to be more of a full-time thing right well that's no not so recent anymore that's been just over a year now really yes that's replies yeah so one of the cool things out of this is not only if we can get and you didn't mention this and Derek didn't mention this at all but I want to say it that if we can get to a point where everybody's using you know X debug not only would be great for all of us to have a good debugging tool but maybe this could be a full-time thing for you as well if we're all using and supporting it right so that's that's true - yes there's a link right yeah in the XD bug support there you go nice thanks for following jazz so let's talk really quickly about why we're on this call before we actually get into it so recently you put out a tweet that said something like anybody not using X debug for profiling or whatever in their PHP is an amateur and it it started some fire so we had a mixture of different types of responses and I am I've got a friend named Phil sturgeon who I've been friends with for a long time and Phil on the internet comes across like a total jerk to a lot of people and I met Phil in person and I had a sneaking suspicion he was really a wonderful human and turns out he was and so what honestly getting to know Phil is one of the first times I got to know someone who had an intentionally a persona that came across too who they were and it kind of taught me a little bit do you read nuance now I don't know if this is it maybe you actually think that we're all amateurs or maybe you were intentionally starting flame or or maybe it's your sense of humor so I didn't know so I wanted to give you a space to just say really quickly what you know for the people who felt like you were gatekeeping where you get keeping or were you trying to start a flame or what were you doing well it was a bit late at night and I don't know I was how I came there but although the wording of it wasn't particularly very articulate the idea behind is that I still think I believe in which is that in order to be good at any sort of job you need to know the tools and the only way in my opinion that you can well develop a PHP fully is if you know the debugging tools and that includes 60 book ok so you would have worded it more nicely but you you you meant the general idea which is that you know I clarified in a few following ok I saw some of your replies ones so would you say that anybody who doesn't use it is not good enough or would you say you hope that people will learn the tools not good enough but it is so this morning I for my work work job I I had to look into Zend framework because I don't know some framework and there was away while I was running a test and I was not I had no idea why it did to send framework II stuff ya know deprecation warnings because I was learning an old version with a new version of PHP but just beyond the point but to not do the rest of my tests mm-hmm and how can you find is this issue out he counts with things like Vardhan because first of all I don't know where to put it yeah the only way how you can find it a single stepping and then finally you find out officer well maybe 20 minutes or so that's my tests never run a grab because then framework calls exits in the middle of it which isn't particularly useful and I don't think that she do exam right so there you go that's like although I don't write a lot of PHP code myself anymore if I didn't have a debugger for that I would have cost me they got it so it was just I wanted I want to say a hundred percent clearly it is a useful tool that you think everybody should have the opportunity to learn but it is not something that if somebody doesn't use that remarks on whether or not they are an amateur is that true I think it's a tool that you should learn it is it's this is a thing I recently started writing go codes and go is it's different it's a compiled language and the first thing I did actually was to figure out how do I do work out with but that are written in it and it doesn't mean I don't use far too important of sense but alone that is never going to be enough you're going to save so much time by actually using a step debugger and that is either and go but Dell for gdb for C programs or anything like that right so Stephanie buggers say to serve all the time step debugger save time oh yeah absolutely yeah so that's what that's where I'm gonna walk from is is in and you know one of the things I mentioned people said is you know you you responded to Derek and saying hey let's work on this together I said well first of all like anytime there's big attention paid to something it's an opportunity for us to all learn and grow and and second of all like let's figure out what the good truth is out of the the drum and if the good truth is step debuggers are used for tool useful tools and if somebody chooses not to use one in my opinion they should choose not to use it because they choose not to use it in that particular moment not because it's something they don't feel like they have access to right so if we can come on the stream and make this particular step debugger which is the only one in PHP that I know of something that everybody has access to well great then that that allows us to make our own decisions exactly yeah I mean there's nothing wrong with using a Vernon buddy deal here or there but it's human being in my opinion will be your only tool that you're using yeah if calls for that sometimes and all the times it's not going to get you where you want to be yep and that's it's very just mentioned right there he said as a consultant I don't know how I could actually learn a new code base without a step deeper go but I also use part of daily so what we're talking more about today is adding a tool to people's repertoire for when they want to use it absolutely all right so learning somebody pointed out that I had not updated my titles which is also one of the steps I normally do at the beginning learning XD but live with Derek how do you pronounce your last name by the way I say it at Hans breath tons all right not read in Susanville yeah I'm never gonna get it perfect but all right cool okay so great so what we are going to do is so first of all in the past there was a standalone X debug client and I actually was able to get it work to work and a lot of times my problem has not been getting the X debug itself installed but getting it configured together with my IDE I presume that that's true for most other people we're getting our Steve bug installed is usually not the problem it's integrating with IDs it's a problem which is why if you just have you know PHP store or something like that you're probably just good to go right most even that it's not always as trivial because I mean the the biggest thing that people go to don't realize is that it is not your IDE making a connection to X debug mm-hmm is xzibit it needs to make a connection to a ID now got it so if for you if if in your networking setup you have exposed everything for your ID to talk to XD but that doesn't do nothing no it doesn't do that yeah so that is the the biggest misunderstanding sometimes of setting up your networking for this yeah and modesta v thank you for mentioning that one of things I would love for you all to chip in with is he's gonna get me set up on my machine which may prove to be extremely difficult relatively or extremely easy relatively we don't know which yeah but all of the rest of y'all this is a perfect opportunity for you now we might not be to answer all of them live but like I would love to get to the point where the result of this conversation is we at the point where everybody who has had trouble with XD bug in the past can either get the answer now or we can recognize that there are resources that need to be created and in order for that to be easy I would love to be a part of us making that as easy as possible so all right so we're gonna do vs code today so for anybody who doesn't know let me just kind of walk through this setup that I have right now I've got laravel valet which I think it's going to dock slash valet so what valet does and a lot of folks who follow me are laravel users so they're familiar with valet but anyone who doesn't Valley is an all-in-one bundle tool using homebrew that basically installs enginex india vns mask bundled in the app and then it installs other dependencies including PHP using homebrew so I actually just last night had to switch my PHP version so we have a brand new fresh version of PHP 74 installed by homebrew and that's what's serving everything so when I visit something like you know I should have spent let's spin up a new afro click in the background or lambo Derrick is my friend so well oops Lambeau knew we just changed the syntax on that is my friend Derrick Lambo is just a little decoration thing oh so I'm in the middle of working on a beta of Lambeau so we'll just use the layer else dollar it's good I've done it in the last few streams we've been working on um on Lambeau so all right so that will end up at Derrick is my friend test and we will be doing all our testing in there and then I'll be using vs code for this one I switch between vs code vim phpstorm and sublime text but I understand that it's very difficult in sublime text and relatively relatively easy obviously still work on PHP storms so I figured since vs code is my daily driver and it's that for a lot of people why don't we start there so mm-hmm John sugar says set up for command-line debugging versus web app is different also debug in PHP unit tests is good to cover okay so we'll we'll start with the mostess just come on line so that students should be no difference okay yeah I think that the main thing we're gonna do is just kind of try to get the webview working and then we'll try and get a yeah we'll try and get a test working so we've got Derrick as my friend at test working now so we can load it we see this so let's assume that it's something in the framework that is not working the way we're expecting just so we can get something that kind of digs kind of far down the call stack so he's okay Dickey what's now running your website which web servers that so that's something that has just been started or that you already have running it's already running so this is nginx so nginx and DNS mask run full time and DNS from ask routes anything at dot test over to nginx which then serves Valley's default configuration and what I taught valet is that anything under sites should be what's called parked in valet which means then it basically creates config file for the directory test ok and that runs PHP obviously mm-hmm but just that PHP have XD book I meant you mentioned that you met you mentioned that Fairleigh install speech be with homebrew mm-hmm you come and select a packet homebrew anymore because they mess it up ok so then that might be a part of the process um would it be in PHP - iPhones in there what was the easiest way to see solved HP - V is the easiest ok oh yeah because it says with XD bug somewhere normally right so no ok alright so first step is how do we get X debug installed with homebrew yeah can you type which Beckel Peco yep so I'm glad we're talking about Pecola because I recently had to learn we learn all about Pecola having not touched it for 10 years probably and I used I didn't use a Mac last time I use Peck hall and so it was a little bit of a dance so unfortunately we're not gonna be able to go through the how to get started in Pecola like normal here because I've already done it but there is an initial step that you have to do on a Mac for everybody just you know the first time you use Peck oh there's one step you have to do Derek if you do it frequently you can share I can't remember exactly what it was I don't use in Mexico know what it is on the Mac it was in my Linux on my Linux system you need to have compiler tools and salt but of course I have those anyway ok so that let me just there's one really quickly thing oh look just some McCreery friend of the show has the thing well this is pair though Paris the same doesn't matter yeah but MIT he's installing it differently than what we did then though but you have Beck will install so you don't need to install it yeah I didn't have to install it but the first time you used it I had to do something to add it to my PHP config file it was something like you basically find what your peck old config Direct and then you you add it to your config somewhere know what Jason's here hey Jason go ahead so somebody's asking Carrollton solid using homebrew no because very well recently like last year they removed all the PHP backup packages from home Brooke so now you need to use backlog and this should not be hard yeah there's just one static so you would need to Xcode stuff installs first yeah okay just what you see yeah it's the Xcode siphons lux okay so let's assume that this is fine and I'll probably wipe a laptop sometime soon and make sure that I can get a full walkthrough of how to get it all installed but I have pecco working so I can keep going through you had a rich pitch if you type which PHP is the same pulse mm-hmm just making sure it's the same pulse because sometimes the PHP and Peko tools are from different PHP versions yeah and then it doesn't work got that something needs to be aware of okay now we have PAC oh and it looks like asteroid one if it's not we'll find out soon enough if you type echo install XD bug just like that yep I can turn I'm gonna zoom up for everybody over you shouldn't take that long alright need to download it first this is something I run 700 times a day and I was configure data does caching in the background and it uses all my 24 cores nice so it takes literally a second or two today yeah sorry Jason mentioned that so in terms of the the recent change to homebrew so sorry to interrupt just for one sec Derek but homebrew used to come with a lot of things bundled but not only was a lot of things bundled but you could also install basically extensions through homebrew so that's why you probably in the past refused to use laravel you installed something like PHP 70 - M crypt or whatever though none of those things are there anymore you now get PHP and that's it and then if you want to do any extensions including some of those ones we used to install the homebrew or new ones if you XP bugs new for you you now have to use Pekka for all of them so if you have not yet and you're a Mac user you're gonna need to get familiar with the pickle all right back to you derp I know it seems to have it seems to have compelled it says extension XD but Knable of PHP I know for me that never does it I'll kind of try PHP - v hey there we go excellent so if that had been oh if that had not worked would it be the normal process where you go to PHP die and I and you add the yes yeah cool yeah so for those who are familiar if you're gonna add an extension to your if you add extension in your machine you also have to add it to your PHP I and I and this could be helpful your for you because if you add this extension and then switch PHP versions you will likely have a different PHP dot ini and so usually at the top of your PHP dot ini file you have to add something that basically looks like extension equals now ignored I'll call the section adders does nothing I would always recommend to have an empty PHP ini just wipe it clean and only make the changes that you actually have to do okay can you say that say there again I always start out with an empty PHP i9 and only make the settings that I need to know you delete all the the ones that are in PHP too high and I by default yes okay okay don't even copy to file as the one of the maintainer zuv valet I'm not sure if I would recommend that because I think we ship certain defaults out of the box in PHP deny that want you to have in there but I'm not sure so I'll take a look at that later but in in the end you do want something that says something like extension equals debug X debug data or something like that basically write it it is there's no braces and a descent and the score extension is XD vocalism okay cool so yeah so and that that is do we get directions here and we I guess we don't so if somebody needs to do that go ahead so the thing is it in your output it said that it's configured it for you in my case it can't do that so that tells you to do it oh okay so if it doesn't work for you it tells you what to do it's not like it tells you it did and it fails okay great and and if you scroll up a little bit mm-hmm so just there's a message you scrolling class or a message yep let's write now that that needs some updating actually I see that now I never look at this it's got extension it serves an extension yeah yeah but it says disregard this message because Oh Nicole used to always tell you to use extension or exhibit that does not work got it okay the documentation links out outdated so I'm going to fix that okay so this is great question fabbi is actually live debugging folks who are asking questions in a stream thank you so much my friend thanks Gary yeah all right but it sounds like it is installed now but that doesn't mean that the debugger is enabled mm-hmm so that is one step that you currently have to make is that you XD book by default doesn't enable most of its features because if it do did that everything would be way too slow yeah and it also makes no sense to have the profile and the debugger going on at the same time so that's something we need to enable okay first of all we need to find out where your PHP ini file is and you can do that by typing PHP - - I and I really I've always done PGI and then grep for it yep this is this is better this is better because it also tells you the exit or the additional PHP ini files that are being parsed that's amazing yeah and I do think that we if you go if you add any files into comp D they just all get loaded alright yeah yeah so that this is what I recommend is if you do want to have a blank file in valet at least just go add extra blank files in here for your own work so yep and it doesn't matter with our names okay so do you want to just to open that up or you just wanted to see it yeah no we need to open it up but we need to open up the standard up php.ini because that's where Paco install see these things which I I don't think it should do but that's what it does yep so there's our Zen extension okay XD bug yeah it just puts it at the top because who cares right yeah PHP doesn't either so you need to make one extra setting here which is XD book dot remote and the score enable just do some nice and boolean I don't I'm not sure about it through works I know that one works sure all right just like that just like that all right yeah what's next okay if you should be enabled now okay is there any test we can run other than just starting to try to get it working in vs code to make sure that we actually have a connected right so I wasn't quite on talking before you close within a very very useful thing to also make a setting is to create a log file mm-hmm because it will tell you exactly what XD work is going to attempt to do and that it can make a connection on so that the sex debug dots remote underscore log allergy equals and then apart I usually put in /tmp I'm not sure what that is on Mac know you need to specify the phone okay so not just a director don't actually know nope there you go cool yep and then yeah I do actually but good luck but that are perfect okay now if your middle if you are no recent Linux that run system D it will put it in some different private stem direction Oh within here okay but you'll keep that for some awesome okay it will not make any food and put anything in there until you actually start making goddess I can't call so we should go make a requester is there more first well you need to restart nginx or PHP first all right sorry mite this is the killing me alright so brew services you said or just either one well PHP it's the one that needs to be restarted okay I don't think you have to do PHP fpm yeah okay so brew services restart PHP let's look at the chat looks like things being held there is a trex debug yeah so proposers do saying people are amateurs if they don't use exercise well so herbage a that was best you know you're you're saying that somebody's being an and you're kind of being an by doing it so while you know I understand that you may think that that wasn't the appropriate way to say it and it sounds like it sounds like Derrick may have agreed that that wasn't the right way to say it when he mentioned that it was a little bit late at night there because it's it is that safe to say that you you think that that was maybe not the best way to get a good about your message I don't I don't want to put words in your mouth I want you to say what you're saying but I want you to have space to say it here so it wasn't the best phrasing thank you so if someone has acknowledged this not the best phrasing then let's not be to someone who we felt like was being an so yeah okay cool so we restarted PHP so in theory our request should be working what's next yes I'm not sure how you do this with laravel but it is often good to see the PHP info output to see where there's actually loaded for the web browsers oh okay or sorry in a web server so they just take it at the top yes okey is help but it does the job yeah so just for anyone who knows the first thing gets loaded on every laravel request is public site the flash index dot PHP so if you ever have to do this you just throw it at the top of that file yeah it's the same for Sun frame because I found out earlier today yeah well that's interesting font switch that it just did all right so should I be searching for anything for you or search for XD book yeah I didn't see anything oh you know what last night when I switched I got 74 on the the the web and 73 on the command line awesome ah I thought I'd fix that okay what's the fastest way to fix this that doesn't involve tooling around with homebrew all morning oh goodness yeah that is a tricky bit right and see this is why these things get tricky yeah well the answer is so in theory there's a valet has a tool for valet use that I helped write which is why I know that it's imperfect unfortunately where it basically stops PHP and then kind of real inks all the things and it was using PHP this valet used thing that went wonky yesterday because my old version of that is what's being problematic I'd rather surface I'd much rather we do this with um with homebrew versions good yeah well it's probably easier yeah the problem is I don't want what's easier for X debug I want what everybody's doing you know II mean because that the whole goal here is saying what are we all doing the problem is yesterday I was working on a project and I pushed it to staging it through a whole bunch of errors and I realized it's because the project had upgraded to the server upgraded at pH P 74 which I did not know okay so we're on 74 locally so probably have to redo yeah reload some of that but you need to be you need to be careful because this PHP 7 form might be a different installed on the command line stuff yeah so we at least they're both 17 4.7 so let's see I got it if you make it no go to PHP info output mm-hmm in a browser mm-hmm you need to leave at the moment because the video isn't good enough for me to see it instantly Oh got it let me zoom in a little too it's really tricky to say so it says prefixes user local seller PHP seven four seven so that is the location where homebrew installs PHP mm-hmm and that is all step eckel that we need to use from there as well yep so we don't have to check in there what like the exact part is of pecco change your part and then run PHP because I don't believe that is to write on okay so let's go to user local bin and see I think it wasn't seller use a local seller yeah but it has don't let correctly yeah exactly I just want to show and people I assume will do the same but it's too oh yeah so it's the same one seven four seven for both okay so that's good to know if you type PHP - Pete does it still work yes debugging spec oh yeah exactly all right so then and then we grab that no you need to be you actually have to fully reinstalling Oh got it okay so I was pickle yeah seven seven three and seven four counts use the same binary got it okay all right well this runs people people in the chat we're running our PHP containers with docker where this also be tackled besides of locally running it will not be tackled in the next thirty minutes but I'm sure it'd be great for somebody to to do that conversation about that at another time where things is oh good one of the things is that we've had several blog posts in the Titan vlog about X debug because one of the folks at a Titan Jose Soto it's been a lot of time trying to get everybody working so he actually wrote up instructions a couple years ago about X debug with homestead in vs code and then also with I don't know what this one was on so there's a couple things here and I will make sure that anybody who uses laravel has as many resources as possible for X debug so and you know Derek obviously already has some Reese's out there but if there's something yeah as we say if there's something that you all need let us know in the stream and then we'll be able to tell you whether or not that exists because if Derek here's the things that people need that are keeping them from using it that will help him kind of know where to build documentation and stuff so in the end where I want to end up is that these posts aren't all over the Internet's yep there's a section section on the documentation where you pick your combination and it will be content either for a link or just all of the same format so that is easy to pick up and see the difference between them yeah it sounds great all right so in theory it's enable already gotta pee okay cool so we now have the same version on the command line so we do we need to go reenable everything though use yeah you need to do that yeah so what did you have me do is XD bug dot something remote in the score enable mm-hmm cool song and then next and then I lock you know log equal slash tip / what did I name it XD bug that log look good alright let's restart PHP alright through services restart PHP dry phpstorm you can add new buggy bugs to the GUI yep I'm super happy I'd be happy to stream where you bring your environment now great that's awesome go ahead Rafi Rafi the IDE key is not necessary or shouldn't be necessary the REE key is something that browse the stem to log down to but on the X deep oxide that shouldn't be necessary it's only necessary if you have a very complicated setup having said that NetBeans requires it to be a specific value but that is something you don't have to do in PHP ini but we can be that you can set the two browser extensions already so we don't have to worry about it right now all right and yes this is more complicated than it should be and that's all changing an XD book 3 so this is a bit of a point where I don't want to spend lots of resources writing all the docs for XD book 2 because it's going to change them 3 anyway got it what's in Taiwan x-ray I hope I hope to get at least a beta out by the time PHP 8 comes out ok and when is that I don't actually know that's coming out PHP 8 is November 26 okay so hopefully a beta by the end of November and cool all right so all right so where do we go from here do we now want to go do a request so we can see if we have logs we check PHP and five put again all right I don't even in film all right and then check for X debug there we go and if you scroll down further they should check also better remote enable sternum because I sometimes make typos it is on yep no good okay you don't have docker or anything installs it is installed but I'm not using it for this right sorry PHP is currently not running in the docker container correct yeah okay fine then that should be it on this sides okay should we check the log next err but nothing should show up in the lock because we haven't attempted to make any debugging connections mm-hmm but that's a good first step okay you're using Chrome here yep and so this is my workflow and I'm not sure whether everybody likes doing it like that but there are so many different possibilities that I'd like just like to stick to one okay and I never enabled debugging by pressing go in my ID I always have phpstorm just listening in for incoming debugging connections and initiated a deep in connection with a little browser extension okay which I don't think you have installed I don't know if yeah go ahead manage extensions now I followed by a link of the a that's what I can't remember so sorry try that since I cut out for just a second key say it again I didn't hear you okay if you go to XD book dot orc slash Docs slash or remote yep at this right-hander nice well scroll a little bit further down there should be three different extensions I have rewritten it there we go so does a link for Chrome don't click on this oh I do have installed oh this item has been disabled in Chrome though so I had it but I had turned it off all right so you can close the screen again okay so there I can't see the distance I can't see it either it should be here it doesn't help if I point my mouse pointer position I'd like it to see ya Oh God it shouldn't show up in dis screen that shows up over here yep well it's show up over there yeah let's um let's pull off the PHP unit real quick alright sorry though the PHP info and see if for any reason that might help us alright so we still don't see it here okay go to manage extensions and see what it's tested on I've never had a problem with us is it alright so is it enabled it is enabled it's in Ableton all sites all slides no it's inactive did you change that where's it inactive sorry it just I saw a change where it says inspect fuse on page two inactive don't know what it is I have no business it says click the alert by your avatar new extension added application launcher yeah that's just a note about that allocate of that thing being added all right so yeah so it is on it's using version 1.6.2 on I think this right here is just allow you as it's just a your you can see something about OS they don't even know what that is yeah nevermind okay alright so if that's not clear we can why we can't restart chrome because you're in Chrome I could fully understand then reinstall it rather than just deactivating and activating it I say gift let it go okay thanks for following tizzy all right so I actually just want to try here and just see if I were to ask for a new extension how do you search for you know what never mind we're just gonna go the way it worked cuz it worked X Diva org slash Docs slash remote and then search for the word Chrome so Robin makes a reasonable suggestion yeah that's a good idea alright music attention by clicking on this icon which is now there all right okay so soon the difference both never expected it to be well the interesting thing is it went away after it said that so it did still it's a different spot but it still wasn't there so we'll try Robin's idea i hopes mantini no it does not seeing it command shift X when I hit command shift exit shows up but when I don't I think there's goes away there's just too many icons so click the puzzle I thought it will be you have to click the pin there oh I have to pin it for it to always show up that's new ok there we go oh that's cool well can I get rid of some of these in Jewish okay well other things I never click you know I'm glad that it's working but it's not like I ever actually click it so okay cool thank you so much Donny soon all right cool so we are now live ish so now I click home debug alright request page here all right click on click on something I don't know these all take us off the cider enough that matters well yeah it does matter it needs to be something that runs on the side ok we come debug laravel calm yeah routes hopefully we can't stupid okay that should be fine but okay because we've we've now tried us there should be something in active a good luck for all right oops there we go so that works fine of course it doesn't work because this can't connect to your client yeah alright so we'll just tell that so if we need something we can get back to it as I know this law will list all the connection attempt but also the full communication of the protocol mm-hmm so once you have established it works I recommend you turn it off got it good note yeah otherwise it's gonna get pretty heavy pretty fast yes okay alright what's next we need to get via scope going alright alright this doesn't particularly yes now and this is the bit where I am more unsure on okay because I don't use it so there is a plugin for visual studio that I'm opening it that looking at here on my screen said I'm looking down yeah Norris which is called PHP debug now I it's s installation launched via Scott quick open control P there might be command P and then ty next install X install like that XT XL HD extension install yes next space install mmm-hmm our X to install statists now X space install yep yes a space and then it is Felix Becker Feliz artists the drummer named I'll have to spell it like that see yeah yep dolts PHP - debug all right so it says no matching commands but that's I assume that's the name of some somebody's extension right can I just correct yeah let's so I've got the extension marketplace right here let's see if I can see it here PHP debug by Felix Becker okay cool yeah that's still on so you have it insult so I've installed already great now how do we use it that's something you're going to have to find out together because I don't use it so I don't know okay god I'm so going by the documentation it says install XD book which be dumb that you can configure PT PT use XD bug don't let sir so it recommends to make an older setting in PHP I not but we're not going to do that okay because your browser extension is the equivalent of doing this and buying an old setting remote how to start you can select by each page by enabling it in your browser whether you want to make an even connection or not okay so that's an option you have if we were debugging command line stuff or unit tests would we need to turn this on then technically not but it is easier okay so the simplest answer for people who are just getting started is if you're using your browser only for X debug you should use the the browser extension but if you need I would recommend that yeah uh-huh but if you need it to work in PHP unit or for command line apps the simplest solution is to turn on remote auto start like this yes okay cool yeah and also that having that XD book having me means nothing but that's fine okay that's okay all right okay so we've done that mm-hmm we have verified with PHP info and we also already know that XD book is making connections trying to make connections mm-hmm so now the only step that we need to do is if es code configuration all right so I'm for that in your project go to the debug and hit the little gear icon and choose PHP whereas the little gear icon maybe this one okay well it's not the debug though so I'm actually pretty new to vs code so there's folks on the stream who actually are much more used to this so I'm gonna have to yeah that's something rely on them so I think there's probably like a debug up here but I don't see it there's no um on the right debug play button with the little bug sit he says oh this one right here okay and then open a file but it's telling you so there's two different options here you can either initiate a debugging through feeis code or by requesting something in your browser mm-hmm you want to promote I'll to start if you do through vs code which you use a browser extension if you do it for the browser so yeah they listen for your ex debug option that is the one you need to do okay in the the way how we are setting it up right now so this says in your project go to the debugger and hit the little gear icon and choose PHP a new launch configuration were created with you for the two configurations so so far this is the only gear I kind of seen Colin Hall says it's in the plug-in list where install was which would be I thought install was right up here but I don't see anything about what you're talking about there Colin could you tell me oh this gear icon right here that can figure on the thing itself oh I see I don't think so cuz that doesn't say PHP anywhere in here it's it's saying right now go to the debugger and hit the little gear icon so let's find maybe there's like actually a debugger portion of vs code that we need to find open configurations maybe since we're supposed to be configuring PHP there you go now interestingly it does say Chrome but we're gonna try PHP great these are our two as well right so just to answer you see on this chat it isn't necessary to install directive of browser extension but I find it work better okay all right so dis looks okay all right listen for XD book I'm they misspelled it but that's okay with me is there no capital on the D no got it it doesn't matter yeah all right so that's that's what they wanted us so when they said that that's what warrants to do so anybody needs to do that you if you want to configure it you can go open configurations and a PHP that's exactly we wanted this setting will simply start listening with specified port if you configure the X debug like your recommender above every time you make a request with a browser your web search so this is what we're talking about is the listen for X debug so now how do we enable that version that should already be done from what I understand but there are a few options that just sometimes might have to make but because everything for you runs on the same machine should need to do anything so in theory that's happening right now go ahead so Ravi is asking do we need remote ports you only need a remote port if PHP fpm an XD book wrote you support 9000 unfortunately that is the default for both so we might have to change this okay um so I don't know how to use this on the Mac can you figure out which port PHP fpm uses I know you can't I don't know that I know does anybody know how to do that on Linux it's nuts tat but I'm not sure about it works on the Mac sorry a terminal yeah it sounds familiar so let's just try it come on ok uses 9000 by default with valley ok just you get a very long list yeah so we're gonna grab something out of here just use less that should be in the top section okay okay Bobby says you need to change it okay cool so we're gonna config both our I and I and then set erect you me okay so as debug remote port equals 9 9001 let's just do let's do something weird oh good yeah I think I'm changing it to 9000 and 3 for X equal 3 ok and then so we'll make that same configuration setting when we say open configurations and then we say 9003 oops yep what okay my fingers in the wrong spot and we'll do it here to that cool yes okay so what other options can you say here I think we should just try and see what happens okay so we need to run a we ready to listen for debugging connections I think what that's going to be is run it using that particular configuration yep okay so we're in the we're using the listen for debug configuration right now which make make the request in your browser and see what happens all right all right so I assume that we're gonna see something down here well it should already have gone that's yeah so we didn't see anything just on the basic request take your V start PHP that's a great question port I not after changing the port now Bruce services restart PHP Nate says you didn't click run but I'm pretty sure I did that's how we got to UM this right here this purple thing Thank You purple okay nothing do I have to click at why they have to close I'm pretty sure it's running that's why it's pink right now we see the debug console here and maybe he got maybe means the play icon on your right-hand side it's a fort icon from the top oh no there's a tiny toolbar in the middle of us code at the top you have to reload that thing I don't see it's this singer here okay check look output to see whether the port's changed yeah there we go yeah you saw something yeah yeah there's this icon says run I yeah but I think I think that just started this right okay so Robin said reload this but we did reload this this is this is running I'm pretty darn sure this is running otherwise it wouldn't be pink this right here says no problems okay they were seeing nothing in the debug console and then Donnie says do have to add a breakpoint for anything actually show up here you know vd we first need to verify it in with the XD per clock that the connection actually happens okay but I don't see anything so so let's we hope if we just load this we got these three requests so the poor didn't change so it's all in doesn't still good catch yeah the problem means we changed maybe mistyped it or something maybe yeah all right so this is peach p2i and i XD bug remote underscore port that's correct okay maybe just set somewhere else can you search for it well I grep in there can I search for it in PHP try well yeah or don't do that that works no okay I'll do you actually port so it works there let's change that yeah oh yeah yeah all right there okay so let's see let's do another restart but it's possible that this is one of these things where our command line and PHP fpm you have to restart PHP fpm separately I don't think so no can we get it out of PHP info yeah yeah let's do that I want to see if PHP info is not showing it picked up because I want to make sure it's not my connection that's the problem here yep see it's it's picked up locally but my my it's a so it's like you using a different php.ini phone let me just try this real quick this is a little bit of a nuclear option where it restarts all of the services that Valley has and every once in a while that helps you okay I will answer questions yeah go ahead John sugar saucing is he is code configured to look at 9003 yes we change that Babli we had restarted PHP but we did not restart the entire valet so we're gonna restart the entire Valley which also then restarts oh there we go I don't know why it actually threw it exception but it's connected so I'm we almost if he burr is a stack out so on the right hand side you have to call stack game a bit bigger yeah a bit wider yeah and then the talk I've never seen this and then the top right you have your your variables mm-hmm so you get your exception then you get your local arguments I would close the watch screen because we don't really use I don't really use it I forgot it okay you have a bit more more space so it's call stacking variables are the ones we're gonna want to be thinking about right now okay just click on one to go back to go back down the stack yeah yeah you got a background a stack yeah so so I don't know why fee is code by default pauses on exceptions mm-hmm that is a choice that vs code makes right here we've got thing that says breakpoints everything so we could choose to contextualise that yep yeah so if you turn off everything that it shouldn't stop that exceptions yeah oh so that's exceptions even if they're caught that's why I did that got it yes okay even if they're caught yes okay so well I also I mean I also don't don't know whether vyas code allows multiple debugging sessions at the same time mm-hmm but if the current one is going you probably want to stop it this granite top mm-hmm and then try again try again okay so do you need to do that between every request then if the request runs all the way through the end you don't have to write as soon as it catches something you got to stop and restart yeah okay got it so now if you request your browser again yep forget nothing you got nothing because there's nothing happening but right to make sure that yeah we can still verified in the locker mm-hmm and I think it's looking at the timestamp because you can see it connects with the inert packets then it's does a list of all the breakpoints that are set which is known if it just starts yeah and then add run to run and because there's no breakpoints are sets it runs all the way through the end without actually showing you that anything happens got it so yeah okay so because we're sure on time first of all thank you because it works on my machine now and that's a different setup than I've heard recommended from a lot of people obviously we've had people in the chat talked about getting it connected with phpstorm we've had people talk about getting it connected with docker and then we've also said there's you know like there's apparently different ways to connect and I would say that I will always lean towards the way that the person who built the thing recommends that I connect as long as it doesn't make my workflow miserable and installing a chrome plug-in doesn't make my workflow miserable at all so that's great and I love the fact that we have this thanks for following blue diet fish so I would say is there any one last thing before we go for today obviously there's a lot more to do in the future where we should give an example maybe of a way that X Dig Dug would be really helpful so what you have here is narrow routes varies callback function mm-hmm if you set a breakpoint on this line 17 mm-hmm I think you can just click in front of 17 I don't know if isco does that yeah yeah just kill the low I'm low thing right there all right okay not sure what the difference is between the circle and the red circle but I think it's red if I'm hovering and then it's a normal circle yeah it's just a circle if I clicked it yeah all right now re-request it and it should stop and dislocation where you wanted it to stop yeah let me get rid of that um this right here perfect so it's in the middle of rendering the view we can see what all of our super glue Global's are including all the env we've gotten access to I don't know if we have anything else that's of interest no but what you could do is step into view by clicking the step into button is that already oh yeah yeah it I think is that that one yeah and then you get to step step by step to see exactly what's goes on mm-hmm so what does you scan what a step input into you mean just lower down the tall stack step into this go to the next executable statement got it okay so we'll tap over it's go to the next line in the same scope okay and step out means finish running this function okay got it thank you that's very helpful so as Renee is just just basically hit keep going into here the next breakpoint until you're done or okay got it okay so step into we're going down the stack and what you all I mean if you've ever seen the laravel stack trace before we're basically working our way down what it looks like for laravel to resolve something out of a container here so most of the time when you're doing these types of things you're gonna be doing that if you're trying to learn the framework but if you're trying to debug your own code you're more likely to be in a circumstance where you're you know calling it through your own call stacks and seeing which variables could pass through so if we could do just a really quick test run or something I just well I'm trying I wish I'd meant to build something ahead of time oh can you go back to the previous step says see the CDR UK no there's no step back at some moments okay so what we would end up doing probably is if we were expecting something to be passed to one of our internal classes and something else gets passed so let's just really quickly you know make a function do stuff variable and we're expecting to have you know what do we have you welcome with the stuff equals variable or something like that are you not letting me type here variable so if we were having our problem not you know it do our so - sorry return do stuff my best variable so if we were in a circumstance where you would what's that good it's the bestest variable it's the bestest ever yeah so if we were finding ourselves in the circumstance we would often you know be multiple lovers layers of nesting down we weren't sure exactly which version of the variables being passed and we're trying to figure out why so we're putting Dedes in here we say DD variable or whatever you know whatever so at this point the idea is if I want to know what variable is here is this my best point you know to do it yes okay cool yeah all right let's go hit run right yeah yeah no no but we also did need to because we weren't listening cuz I hit stop so alright well that's interesting why did that not work return new stuffs do stuff breakpoint set although we're getting a red breakpoint so there we are but okay I don't know what's going on there but I think you just clicked advanced often I have a strange why is it not getting caught Oh so there are a few locations where and PHP doesn't realize there's code on a specific line mm-hmm and hence it can't break so that's why it gets the unverified breakpoint warning got it and that's why I was saying that so we it'd be better for us to do it here because this right here is really just a part of this call yes okay now XD XD beck has this fixed uh-huh and this is implemented at phpstorm but I don't think via Scott has opted into this new feature yes got it and it needs to opt in because otherwise it returns stuff that it wouldn't understand yeah and Sperrys talk about that he said we remember you can only add a break point where there's executive or PHP so for example setting a breakpoint at a brace will never fire and it sounds like it's also true for these in these mid settings here yes since X EBIT - 8 X typical actually if it can't see a breakpoint on a line it will go either further down or further up the closest to where it again could set a breakpoint and it will adjust the line number of the breakpoint that you actually have set got it it was your use code fiasco doesn't implement that stuff got it but he is saying something here about how they'd be able to expand and browse variables with deep dependencies that's just about how deeply nested their dependencies are said right so actually what exhibit allows you to do is step as deep as you want without making any of these settings but not all IDs implement this functionality okay got it yes sometimes if this is a problem then but uzo says that is correct you need to make those extra settings and long stuffy long so Jason I think that's all right so I'm going to do one last thing before we go which is if we could have two break points here one before I modify variable and one after I modify variable so we can just take a look at the difference so I have to refresh and then need to make sure you set a breakpoint on their line that has Kodomo yes this one's going to ask how is the best way for me to do this I want it both before and after but there's no executive code before and after so do a breakpoint on itself that would get me what it's it's so will that give me the output as well as the input good sorry no well it does now it should stop just before the function is run just before okay step over and she'd stop on the next line and they should see Oh fantastic okay so this is a perfect test so if we do this right here we're seeing it's my best variable and then if I hit step over it should now say my best that's very well great so if you're in a circumstance where you need to understand well why did this thing got mutton get modified you can break on the modification and see the before and after ferry but you can also do is change the called the contents of my bestest variable what but oh how annoying is it before we start over okay got obvious this code hasn't implemented things yeah JT says I think of it as breakpoints stopped at the beginning of the line that's very helpful yes all right so so vs code we've got it working but as is true with moppy most PHP related things Petri storms gonna give it to you a little bit better all right from my experience is sublime text do you think do you think sublime text support is is actually viable right now console okay I did see a a offer from friend of the show stavi who said that one thing he might be willing to do if I think I read this right where he said people could join a stream with him and say here's your set up and he would help you get set up as did I read that right that he said that one trying to go back to look I think I think he said that repeating it's easy yeah oh you go you pay for it yeah yeah I know he's joking about phpstorm so if I am I'm right about that yes okay cool so here we go is are you Spivey on Twitch I think you are yes TV's Fett okay there you go so good well Robin says this also makes good sense you can do variable equals blah blah blah and deeper oh cool let's check that out variable equals blah blah blah why not hey so it does work so we can modify it so if we were to do that would we end up with that variable like actually output to the screen is blah blah blah yep why it's okay hold on hold on oops sorry go ahead so this doesn't make a lot of sense for for static variables but if you join your debugging you found that one of your condition is wrong because the variable is wrong mm-hmm then you can change it and then continue stepping as if it was the right thing and then later fix your code that's freaking fantastic so we'll hit this and then we'll just say keep playing oops sorry for you keep playing we just gets under my variable variable wait why is that possible oh because I named it I named it something other than variable that's why all the locals yeah I call it stuff okay so let's refresh and then load the page and then so this right here just plays right so I want to do variable oh hell I have to step over because it's about to get modified so variable equals blah blah blah and then I hit enter it's modified and now I just hit the continue yeah okay and then if we load the page over here oh my gosh that's amazing that was the coolest thing ever holy crap thankfully Hall to work he sees your message so he says thank you for all your work for the PHP community X debug thank you this is so cool all right so because we're way over time first of all so do dear dear friend spab e is available for you um so what's your what's your Twitter handle by the way I never know where your savvy and where your other things I don't know I don't think yours do you know what a st. Louis yeah yeah it's gee I don't know he'll tell us in the stream it GH there you go it's never actually your full name that's why I just I don't even call here anymore I'm like you're just a B so so Gary has Spivey has volunteered that if you want if you have a particular setup an X debug that you're having trouble with hit him up on Twitter and he will allow you to join the stream and he'll walk you through the exact same thing that Derek just did with me here Gary will do with you there Gary is a brilliant beautiful wonderful human being whom I love dearly and he'll do that for you I'm sure that Derek is also available although he's probably got other things DX which what's your Twitter handle so people can follow you if they want i'm derek are okay so i thought all right so Derek I really appreciate all the work you did here what is other than using X debug so let's say if X debug works here everybody use it and love it preferably use it the way that Derek recommended that you use it because obviously it's a little bit of a different beast than what is often being recommended so that's one thing but another thing after that if you if you don't have it functioning as a result of this live stream first thing to do is go to spammy /gh splash Garrett yes Bobbi's Gary sorry I've been calling it was fabulous time I don't realize everybody doesn't know that's Gary Hawken so that's the next thing but other than that what do you want for people what is the best next step for them to do so these the only two only Duke that step debugging now mm-hmm which is only one of the things that XD book does there's also things like there's a profiler building or if you've run unit tests with PHP units then a dress code coverage for you if you're new to code base there as a function called tracing which will create a lock of every function call and potentially have a variable that is being set as well so that's quite a lot of things in there beyond two-step debugging would you uh would you join me for another stream to walk through some of those things more than happy to okay so if you have trouble getting it set up hit up Gary Hawkins which is GE eh on Twitter or spammy on twitch and if you need other things or have suggestions for the documentation or whatever else hit Derek up at de Ric kr on Twitter and if you want to learn more about how to use ex debug in more new and wonderful ways stay tuned and it will go out on both on our Twitter's when we schedule the next one I think at some point we will have to do one where we run PHP and docker okay or Garrett yeah somebody needs to do it yeah and like I said um Titan Arne has a few people a few articles out so will will I'll probably do a really rudimentary collection of all the articles that are out there before it gets all in the docks so that we can kind of have some of these things gathered together before 8:00 and the new documentation is released and obviously Gary's a huge resource and Erica is it between all of us my goal is not that anybody feels pressure to use X debug because you all know how I feel about anything that's gatekeeping me but my goal is that everybody who wants to use it has the ability to use it because my goal is that everybody has access to the tools they want access to so Derek I really really appreciate you reaching out so quickly for making the time for this to dealing all my video issues and thank you for making X debug it's obviously a very valuable tool thank you and thank you everybody else for hanging out um this will go online as a twitch replay immediately and it will be on live as a YouTube replay in a couple days maybe even later today depending on how fast I move so all right thank you all so much and we'll see you all next time
Info
Channel: Matt Stauffer
Views: 3,682
Rating: undefined out of 5
Keywords: xdebug, php, debugging, valet, vscode, visualstudio, development, education, live, livestream, matt stauffer livestream, programming, live coding, live stream, learning laravel
Id: iloCjuqMdKU
Channel Id: undefined
Length: 65min 59sec (3959 seconds)
Published: Wed Jun 24 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.