Note that my Dockerfile configuration which installs php7.4 and (among others) php7.4-xdebug from ppa:ondrej/php using apt will automatically enable the extension as well, so I don't need to explicitly do that. The second line tells Xdebug which address to use to connect to the IDE - which is running on the host machine, and is a special hostname which resolves to the host machine's IP address. The first line configures step debugging, and also affects how some other Xdebug configuration works by default (notably the default value of the xdebug.start_with_request setting). The Dockerfile also copies a file with the following contents to /etc/php/7.4/cli/conf.d/99-xdebug.ini (and /etc/php/7.4/apache2/conf.d/99-xdebug.ini in the web image): xdebug.mode=debug This was giving me trouble and actually took me more time than everything else here to figure out why Xdebug wasn't working for me when attempting to trigger it from the command line. we could trigger Xdebug using an environment variable on the command line. Thus, my Dockerfile copies a file with the following contents to /etc/php/7.4/cli/conf.d/99-variables-order.ini: By default this is GPCS - we also want E so that $_ENV would be populated, and In my Docker images, PHP's default variables order was set to GPCS - which is not good because Xdebug looks for an environment variable in $_ENV when attempting to detect a trigger from a CLI command. If you have a very specific setup that's similar to mine, you're gonna want to do the following: Variables order This whole guide should work just as well for PHP 8.0 as well as for older versions, though you probably shouldn't be using older versions anyway. The Dockerfiles for the web and php images install PHP 7.4 from ppa:ondrej/php, along with a bunch of extensions including php7.4-xdebug - which, as of recently, ends up with Xdebug 3.0.1 installed in the image. Importantly though, the Docker images for running the web-app and CLI commands are based on ubuntu:bionic - I've been wanting to switch to the php images but just haven't gotten around to it yet. ![]() For SSL in local development I use mkcert, though I guess none of this is too relevant for today's topic of Xdebug, and I should just make a separate blog post documenting that whole setup if anyone's interested. instead of having to remember the per-project ports for individual exposed services. I also have a local Nginx setup for proxying requests to various projects so that I can use, etc. ![]() a Node service for Node-related stuff (Yarn dependencies and the front-end build process)īoth the web and php services run a similar Docker image in terms of PHP - with the difference being that web also includes Apache through which the web application is served.a queue worker service (based on the same Docker image as the php service) for running artisan queue:work.The HOST_UID and HOST_GID are configured to be used by Apache in the web image and PHP in the php image so as not to mess up file permissions and ownership on the host machine.įor those curious, I also have the following services as a starting point for most Laravel projects: It's a Laravel app with a docker-compose.yml file in the project root, which looks a bit like this (documentation, unrelated services, and unrelated configuration settings removed for readability): version: '3' "Running in Docker" is not very specific, so I'll start by explaining my project setup. I spent a couple of hours getting everything to work nicely, and encountered a weird (but in hindsight, sensible) issue. Most of the online guides I've found while hoping for a quick copy and paste configuration didn't end up working, and were in fact aimed at Xdebug 2 - whereas the new Xdebug 3 version changed some of the configuration setting keys. I was also recently starting work on a new Laravel project and decided to setup Xdebug so I could, well, debug. I hoped this would've happened more often, but oh well.Īfter many years of Sublime Text usage, I recently switched to VS Code, as the Sublime Text ecosystem for PHP development seems to be somewhat less active lately, based on my personal experience. ![]() So here's my second annual (as in once-per-year) blog post.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |