Zaher Ghaibeh
PHP Backend developer
I've experience in a few PHP Frameworks, such as Laravel, Lumen and Slim (The last two are used for building Microservices/API services).
How to configure PHPStorm to work with native Docker for mac
Published at Saturday, August 27, 2016 , Categorized under: Other

In the past few days I have tried to configure PHPStorm with Docker for mac, and I'll list how you can do that cause sadly the documentation depend on the old docker version

1-You need to install the plugin

2- Next you will have to restart PHPStorm, mean while you will need to install a program called socat using homebrew using the following command

brew install socat

3- You will have to execute the following command every time you need want to use docker with PHPStorm

socat -d -d -lf /tmp/socat.txt TCP-L:2376,fork UNIX:/var/run/docker.sock

You can read more about socat from this link.

4- Now you will have to configure PHPStorm like the following

 

  • You will need to add the server, configure the URL, by default it will use the old URL for Docker toolbox, and since it cant read the Unix socket which Docker for mac use, we use socat to redirect the URL to the socket.
  • You will need to add the full path for docker-compose command , not sure why but PHPStorm didn't find it.
  • The certification field should be removed, as this was related to the old Docker toolbox and no need for it any more.

5- To configure the debugger you should check do the following

for me, my project depend on a docker-compose.yml file, so I choose that one.

6- Make sure that you can start / stop Docker, so from the bottom toolbox you will find the Docker icon, clicking on it will open it and clicking on the Run button should show the images/containers that you have like

  !

7- Run the debugger (running docker-compose) can be done like the following

And it will run docker-compose and create the image for you, and from there you can find many valuable information about your container

Hopefully this will change later, and it will be much simpler if (and only if) PHPStorm team found a better way to implement it.