Installing Xdebug on MacOS (M1 chip)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello in this video I'll be installing X debug so I've recently uninstalled it from my laptop and I'm just going to go through the process of installing it again so the best place to start is oh yeah I was running into some error before so I was on stack Overflow but now uh the best place to start is on the xdebug install page so if we look at this page the keys we're interested in or the case I'm interested in is Mac OSX with Homebrew so I have PHP installed through Homebrew I can check that by going PHP Dash V actually maybe better is which PHP so we can see it's installed in that Homebrew path and I have PHP 8.2 installed and also you can see that I do not have X debug installed because the output of my PHP Dash V should include as a line here similar to the with Zend op cache when X debug is installed we will see a with X debug followed by the version 3.2 something I think it will be okay so first thing is if we go over to the xdebug website we'll go to our operating system version that we're interested in so if you're on Windows you want to go here and if you are on Mac OS you'll go to this option and um I'm on a Apple operating system with a M1 chip so it turns out that there's a slight hiccup with installing xdebug for an M1 chip we need to verify php's architecture so if I run this file which PHP we will see it's in a 64-bit executable arm64 file so xdebug says okay if it's arm 64 e but you know we get arm64 that's fine we'll install XD bug using this command and if you see the Intel x8664 then you would use that command so I got the rm64 one so I'll install using this Arch rm64 pseudo command well I guess I already had it installed but I just uninstalled it for the purpose of this video and let's see if we can reinstall it now so yeah looks like it's installing we'll go through this step it should give us an xdebug.so file at the end and it does so yeah it says build process completed successfully we get the x debugger.so file and yeah we need to add this path this file path to our PHP ini file so if we want to find that ini file we can run PHP dash dash ini on our command line and it's this loaded configuration file we want to open up so this is my phpmy file and just at the bottom of the file I'll just copy and paste the the XD bug configuration that I have and I'll be using the same I'll be using the same path so the Zend extension path should match what uh the pickle install command gave us so yeah we can actually go to this location and just check that we have that xdebug.so file we do and in terms of the X debug installation that should be it so if we run php-v we should now see with X debug and we do so we now have PHP installed with xdebug version 3.2.2 if we for instance if we comment this out and then run php-v it won't be picked up so we do need this x debug configuration change in our in our ini file okay so that's the first bit here now the second thing to do is actually try and set some break points and some code and see if we can get it to listen for incoming connections so I'll create a new directory here say x debug test and I'll create a file here index.php yes I trust the authors there we go okay so I'll just do a little PHP script here just Echo something out the world Okay so in Visual Studio code what we need to do to get X debug working is we need to go to extensions and go over to I think it's called PHP debug yeah this is the one here so this is the official xdebug extension for visual studio code so you can see I already have it installed um so yeah that's that's the first bit now by having this just installed you'll be able to go to run start debugging and you'll be able to hit that break point on line three but sometimes we want uh for our debugger to be listening and then uh for us to be able to for instance make a request through a web browser and still hit the breakpoint so for that to happen what we can do is go to run add configuration and here's the default configuration and the default should work there's a couple important parts here we need to make sure that the port in this uh in this vs code folder launch Json file that 9003 needs to match the port 9003 that is in our PHP ini file so I think 9003 is actually the default Port that X debug uh version three and greater uses I believe so anyways but I like to be just a little bit more explicit and include the uh the port in there anyways okay so that's the configuration that we need the default seems to work pretty well and if I go and run maybe I want to run this as a server side application so I'll just do php-s localhost Port 9000 let's say and we'll open up that application now to get my debugger running I'll just say Run start debugging and you can see the debugger is is listening for incoming connections now so if I go back to my web browser and I refresh the page there we go we've just intercepted the request and we've hit the breakpoint on line three so now we can continue our application for instance okay so that is about it for the X debug installation video uh it's definitely a it can be a finicky tool to uh to work with and well not so much work with it's a great tool to work with I just find the install process can be a little bit finicky especially if you you know if you haven't done it before and if you're just getting familiar with PHP it can be a lot of new info but in any case I hope this is a useful a useful intro to the subject and helps you get X debug set up thank you
Info
Channel: Chris
Views: 1,861
Rating: undefined out of 5
Keywords:
Id: Xd32LkwUP1E
Channel Id: undefined
Length: 9min 32sec (572 seconds)
Published: Wed Sep 27 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.