- #PHPSTORM DOCKERFILE HOW TO#
- #PHPSTORM DOCKERFILE CODE#
- #PHPSTORM DOCKERFILE DOWNLOAD#
- #PHPSTORM DOCKERFILE WINDOWS#
#PHPSTORM DOCKERFILE CODE#
Still I wanted this to run nicely from IDEA :)Īll the code for the following can be found in here on GitHub. In my case I wanted to be able to run my Unittests with PHP7,īut not have to pollute my Debian Jessie/Stretch install, with a non apt-packaged PHP7 alongside the PHP 5.6.16 that currentlyĬomes with it. Well … say you want to run your unit-tests against multiple PHP versions and still enjoy the comfort of your IDE + Xdebug :P How ?Įasy once you know how, but a little fiddly the first time around :) Step 1: Create a Docker Image with your DependenciesĪs an example I’ll use a typical WordPress unit-test setup here.
#PHPSTORM DOCKERFILE HOW TO#
If you’d like to learn more about Docker and how to use it in PhpStorm, make sure to check out the excellent tutorial series by Pascal Landau, and PhpStorm documentation, of course.Dockerize PhpUnit and Force Idea/PhpStorm to Use it! Using these Docker images will save you a lot of effort and let you start coding in a matter of a minute, or even less! We encourage you to further explore the PhpStorm Docker registry: while we’ve looked at a very simple case, you can use the described technique to provide your environment with, for example, a database, or an sftp server. Now, simply open the page in the browser, and the debugging session will be started automatically: Enable listening to incoming debug connections in PhpStorm:.Have a debugging extension installed and enabled for your browser:.Since we already have Xdebug installed and configured, this will only require that you: To do this, we’ll create the most simple Hello world PHP file and try to debug it following the PhpStorm Zero-Configuration Debugging approach. Let’s ensure that everything works as expected. That’s it: we’ve got everything ready for running and debugging our code! Running and debugging code
#PHPSTORM DOCKERFILE DOWNLOAD#
PhpStorm will automatically download the required image and start the web server: You can now start the configuration from the toolbar: In the dialog that opens, provide the name of the configuration and apply your changes: Right-click docker-compose.yml and select Create… from the context menu: We can now start using it by creating a dedicated run/debug configuration. See here for more details and possible workarounds. The corresponding environment configuration section for Linux will read as follows: You’ll have to use your local machine’s hostname instead (to find out what your machine’s hostname is, simply execute hostname in Terminal).
#PHPSTORM DOCKERFILE WINDOWS#
In Docker for Windows and Docker for Mac, it automatically resolves to the internal address of the host, letting you easily connect to it from the container.Īn important note for Linux users: on Linux is currently not supported. Note that we use the value to refer to the remote host. XDEBUG_CONFIG: remote_host=Īs you can see, we use the preconfigured Docker image comprising the Apache web server and PHP 7.4 with Xdebug. In our case, it will be a single webserver service:
Next, we create a new file named docker-compose.yml , which will describe the configuration of the services comprising our app. To get started, we create a new project in PhpStorm. It provides a selection of preconfigured Docker images curated by the PhpStorm team, which cover the most common PHP development needs.īefore you proceed, make sure that you have Docker installed on your machine: see how to do it on Windows and on macOS.
Probably the easiest way to integrate Docker with PhpStorm is to use the PhpStorm Docker registry. With Docker, you can start developing, running, and debugging your code in a matter of minutes! Your first step will be to set up a development environment: at the bare minimum, you’d want to run a web server and a PHP interpreter (preferably – with the debugging engine installed).
So, you’ve decided to try something new today and started a project from scratch.