To be passed over to the Dockerfile, the XDEBUG argument needs to be set in the docker-compose.yml file. Propagate the argument through the docker-compose You can choose another but this one is fine. Notice that the port 9003 is specified for xDebug client. Just add the following in the php.ini file:
In those same 2 directories named 7.4 and 8.0, you will find a php.ini file. Be careful to do exactly as I did when cutting the RUN instruction in half. It is important that the insert is made in this spot. We insert a condition for installing xDebug, depending on the value of the XDEBUG argument. We add an argument named XDEBUG that can be provided when executing this Dockerfile. RUN useradd -ms /bin/bash -no-user-group -g $RUN chmod +x /usr/local/bin/start-container RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.0 & apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime & echo $TZ > /etc/timezone Here is what your Dockerfile should look like once edited: FROM ubuntu:20.04 This way it will be present in your development environment if you want it, but not on your deployed version. We are going to add xDebug to the container as an option. And in both of them you will find a Dockerfile. Inside you will find 2 directories named 7.4 and 8.0. vendor/bin/sail artisan sail:publishĪ new directory named docker should appear at the root of your project. You need to publish Sail’s Dockerfiles by executing the sail:publish command.
I also assume that you have a Laravel 8 project created. I assume that you have Docker Desktop installed and running on your computer. But since the outcome, for now, is to not embed the xDebug option onto Laravel Sail, I will show here how you can very easily add xDebug to your configuration.
Phpstorm docker xdebug how to#
I understand both sides, and I wouldn’t know how to settle it. Which is an issue being discussed quite roughly on the github repository! I won’t go into the argument. Unfortunately, The Laravel Sail environment does not ship with xDebug installed. And it helps understand what is really going on, which is, I think, non-negligible for beginners.
Phpstorm docker xdebug code#
Placing breakpoints into my code, and being able to watch every variable while going through the code step by step is just great.
Phpstorm docker xdebug software#
Especially when it comes to deployment.Ĭoming from low level software development, I’ve been used to this incredibly powerful tool that is a debugger. I personally find it way more easy to use than Laravel Homestead, that had the same purpose of proposing a development environment in a virtual machine. Laravel, with version 8, introduces a very practical wrapper for a docker environment: Laravel Sail.