PhpStorm with PHPUnit in PHP docker container on vagrant
It's a bit complicated because there is one extra virtualization layer (host => Vagrant VM => Docker), but it's possible.
Let's agree on these:
/home/PhpstormProjects/theProject
is the path of your sources on the host./var/www/html/theProject
is the Vagrant VM path your sources are mapped into./opt/theProject
is the container path the Vagrant path is bound to with volume mappings.
First, you need to configure your Docker daemon to listen on TCP port:https://success.docker.com/article/how-do-i-enable-the-remote-api-for-dockerd
Then, you need to add these Docker server at PhpStorm Settings | Build, Execution, Deployment | Docker
.
After that, add a Docker remote interpreter using the desired image at PhpStorm Settings | Languages & Frameworks | PHP
.
You need to set the following mappings later:
- Docker container | Volume bindings:
- Container path:
/opt/theProject
- Host path:
/var/www/html/theProject
- Container path:
- Path mappings: Add a new mapping (as the default one is incorrect):
- Local path:
/home/PhpstormProjects/theProject
- Remote path:
/opt/theProject
- Local path:
After that, configure PHPUnit for this Docker interpreter at Settings | Languages & Frameworks | PHP | Test Frameworks
, it should be able to parse paths OK.
That's basically it, you should be good to go. Unfortunately, there's no option to pass custom arguments to Docker: https://youtrack.jetbrains.com/issue/IDEA-181088
If there are any issues, please submit a support request: https://intellij-support.jetbrains.com/hc/en-us