Xdebug activates step debugging (because our xdebug.mode is debug, and xdebug.start_with_request is set to yes).With all of these set the way we've set them, here's what happens every time you send a request to your PHP application: xdebug.discover_client_host=true tells Xdebug to attempt to extract the IP of the client from the HTTP request, and xdebug.client_host tells it what to try if that doesn't work. The last two lines are where it gets interesting. I recommend setting this to yes and forgetting about it, but if you've done this before and you know you prefer to activate step debugging only for specific requests, leave this line out and Xdebug will default to trigger. Xdebug.start_with_request=yes tells Xdebug that we want to activate step debugging at the start of every request, for simplicity's sake. Xdebug.mode=debug enables step debugging (which is probably what you want to use Xdebug for.) your php.ini, or wherever you usually configure your PHP extensions):Įnter fullscreen mode Exit fullscreen mode This is the bit you need to put somewhere in your PHP configuration (i.e. Xdebug 3 makes this whole exercise a little easier for us by generally overhauling the way Xdebug is configured to make it simpler, but if your setup is a little convoluted (like mine), it can still be finicky to get right, hence this post. if PHP/Xdebug is running on a different physical machine, in a VM, in a container, or similar - it won't work out of the box. Xdebug can just go to localhost:9003 and hit your client), but if your setup is a little more complicated than that - i.e. This is fine if your setup is relatively simple (i.e. probably your editor or IDE), in order to establish a debugging connection. Xdebug can be tricky to configure, because it works in reverse from the way you're probably used to interacting with your PHP application - instead of sending requests to your PHP code, Xdebug needs to know how to send requests from where your code is running to your client application (i.e. (Don't get discouraged by my ultra-convoluted setup - this configuration should actually theoretically work for pretty much any environment, for reasons I'll get into a little later on.) I recently spent a good few hours getting Xdebug to work with my development setup (which is PhpStorm running inside WSL 2 on Windows 10, and PHP/Xdebug running inside a Docker container, inside WSL 2, with Docker Desktop), so here I am writing up the surprisingly simple solution I ended up with - partially for my own future reference, but also to help out anyone who finds themselves in a similar situation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |