New Docker-Compose Support in PhpStorm 2017.2
PhpStorm has had Docker support for a while now, and using a Docker remote interpreter has been a relatively straightforward task for the last few releases. PhpStorm 2017.2 introduces native support for Docker Compose to make using Docker and PhpStorm even easier.
While Docker can handle single containers very nicely inside PhpStorm, often you should be defining multiple containers to handle different parts of your application; a container for your database, one for your web server, another for PHP, one for your memory cache, one for your queue and so on. This is considered the best practice when using Docker – one container per server, and in even rudimentary systems, these containers can ofter become numerous, with each container depending on one (or more) of the others.
Docker Compose is a tool for defining (and running) multiple container application in exactly the way defined above. You can define multiple containers in a `docker-compose.yml` file which (typically) lives in the root of your project, and then you can bring up your entire infrastructure using `docker-compose up`. This makes managing the web of containers needed to develop and (ultimately deliver your project using Docker Stack) much easier than having several individual docker files that need to be brought up in the right order.
If you’re not using Docker Compose and would like to learn more, I highly recommend this blog post by Matthew Setter.
PhpStorm 2017.2 makes it easier to use your PHP containers defined with Docker Compose as your remote interpreter of choice. When you’re adding your interpreter, still select From Docker, Vagrant, VM, Remote… and you’ll notice the new Docker Compose option.
The Server option allows you to pick which Docker server to connect to (Docker for Mac, Docker Machine or direct TCP connection). You then can tell PhpStorm which `docker-compose.yml` file to use as the Configuration file(s) and PhpStorm will then provide you with a list of containers to pick from in the Service drop-down. The Environment variables… setting allows you to set substitution variables for the `docker-compose.yml` file.
You can select any container that provides command-line PHP, and have multiple interpreters configured per-project – so if you want to have different containers for running PHP Unit configurations, one for running on PHP 5.6 and one for running on 7.1 for example, you can do that without a problem. You can still run your Behat, Codeception and PhpSpec tests using a Docker Compose interpreter, and you can find out more information about configuring those test frameworks in these videos.
Once you’ve configured your Docker Compose interpreter you’ll see that PhpStorm will infer the path mappings automatically from the `volumes` section of your configuration file.
Docker is an important area in both development and deployment so we’re always aiming to help make the integration with our IDEs as seamless as possible – we’re interested to hear what you have to say on the matter.
Note: Please note that Docker-compose configuration version 3 is not supported yet. We are working on it, please vote and follow the progress in the issue PY-22674.
– Gary & The PhpStorm Team
Subscribe to Blog updates
Thanks, we've got you!
Qodana Clone Finder: Early Access Program
In December 2020, we announced the EAP for Qodana, which is rapidly evolving into a comprehensive platform that allows companies to perform multi-level evaluations of the quality of code they own, contract, or purchase. Qodana helps you detect bugs without relying on an IDE, either on a local machi…
PhpStorm 2020.2 EAP #3
The Early Access Program for PhpStorm 2020.2 is in full swing and today we’ve got the third build of the 2020.2 EAP for you. In this blog post, you can read about improvements for Git installed in WSL2 and Search Everywhere. Download PhpStorm 2020.2 EAP (more…)…
PhpStorm 2019.3.3 Preview
We’ve just rolled out a preview for the third minor update for PhpStorm 2019.3. Please give the PhpStorm 2019.3.3 Preview build 193.6494.5 a try and share your feedback with us. (more…)…
How to Upgrade to PHP 7.4 with PhpStorm
Check out our fresh video with a few nice tips and tricks on how to update your codebase to PHP 7.4. It combines materials from the PhpStorm 2019.2 and PhpStorm 2019.3 releases, with a few cool bonuses to boot. Nikita drew our attention to the fact that setters are slower than assigning prop…