I may update this post in the future for linux-specific config, so check out your docker machine in the first place to see if it can be linked to PHPStorm instead of using the legacy daemon tcp socket. Note: I am using Windows, and I deliberately checked the Expose daemon on tcp://localhost:2375 without TLS checkbox in Docker For Windows configuration. If it comes that you have the Server section to be empty, click on New and you may see something like this: You should configure the remote interpreter to use Docker Compose and have something similar to this: You might have an existing PHP interpreter, but for the sake of the example, I’ll show you how to configure your PHP Docker container.Īdd a new “ Remote Interpreter” by clicking on the big + sign: Now, you need to click on the button at the right of the CLI Interpreter section in order to create/use a PHP interpreter. Let’s consider we have a php container running, configured in our docker-compose.yaml file.įor this, go to the File | Settings | Languages & Frameworks | PHP menu. Okay, let’s see ALL the steps that I go through to set this up. If all XDebug options are displayed with their default/configured values, it works! Start configuring! To know whether XDebug is available, run php -dzend_extension=xdebug -i | grep xdebug. Yeah, it’s just about removing the extension. TL DR: it means that you can do php -dzend_extension=xdebug instead of php -dzend_extension=xdebug.so for UNIX and php -dzend_extension=xdebug.dll for Windows. If you have PHP 7.2+, you can even make your debug-based test scripts cross-compatible with any platform thanks to extension loading by name This echo thing is a trick to force pecl to execute in a “non-interactive” mode, in order to let the Docker image be built automatically with no user interaction (which is not possible). I usually install it in my Docker images by adding a RUN statement with (echo '' | pecl install xdebug). Of course now you have a working Docker setup, but remember that XDebug must be present. I also consider you already installed the Docker plugin for your PHPStorm IDE. I will now consider you have a working PHP + Docker environment. Having a working Docker environmentįirst of all, if we talk about Docker, you may refer to the series of blog posts I wrote about Docker, it might help you. I’m only using it when testing, with PHPUnit or Behat, and that’s perfect: it forces me to write more tests. I have struggled so much in the past and never succeeded in configuring this, and I will probably never do it anyway. ℹ️ Important note: I will not talk about using it in an HTTP context. Here, I’m going to talk about configuring XDebug with PHPStorm and Docker.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |