Setup Environment for PhpUnit, Docker with PhpStorm

To add your PhpUnit and Docker with PhpStorm please follow the steps:

Add Docker to PhpStorm

  1. Open Preference > Build, Execution, Deployment > Docker
  2. Click [+] to add docker
  3. Leave default settings. Connection successful message will be shown.


Add CLI Interpreter for PHP

  1. Open Preference > Languages & Frameworks > Php
  2. Select PHP language level
  3. Click […] beside CLI Interpreter
  4. Click [+] of opened window
  5. Select From Docker, Vagrant, VM, Remotecli1
  6. From Pop-up select Docker Compose option
  7. Server should be the docker you just created.
  8. Select Image Name (container)
  9. Service should be php.
  10. Click OK cli2
  11. Again Click OK to close CLI Interpreters window

  12. You CLI Interpreter field should show the Docker container

Add PhpUnit

  1. Open Preference > Languages & Frameworks > Php > Test Frameworks
  2. Click [+] and select PhpUnit by Remote Interpreter
  3. In pop-up select Interpreter (your docker interpreter)
  4. Setup the fields like the image.


phpunit 2

Now set composer.phar

  1. Open Preference > Languages & Frameworks > Php > Composer
  2. Select composer.phar radio option.
  3. Select path to composer.phar of the project.


To add PhpUnit to project

  1. Open composer.json under vendor directory
  2. In require-dev section add the following – “phpunit/phpunit”: “5.7.27” or “phpunit/phpunit”: “^5”
  3. Run composer update from inside docker container’s /code directory

That’s it, you’r are done with your setup. Now to run test simply right click on the test or test method and select RUN. Now you can see that the docker is started before running the test. Enjoy testing 🙂


PhpStorm version used
Version: 2018.1.4
Build #PS-181.5087.24, built on May 18, 2018


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at

Up ↑

%d bloggers like this: