2

I have the Vagrant box with several containers and one container is for PHP engine.

Usually, I run my tests inside Vagrant box like:

docker run <my_specific_parameteres> remote.docker.container.php7.2 bin/phpunit --coverage-clover -c phpunit.xml.dist

But, I want to run this with PhpStorm. It is possible? If yes, any help, because I do not know how to properly configure my PhpStorm to run PHPUnit as I want.

1 Answer 1

4

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
  • Path mappings: Add a new mapping (as the default one is incorrect):
    • Local path: /home/PhpstormProjects/theProject
    • Remote path: /opt/theProject

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.