IntelliJ IDEA 2022.2 Help

Monitor code coverage for PHP applications

Code Coverage for PHPUnit shows you how much of your code is covered with tests and marks covered and uncovered lines visually right in the editor.

Before you begin, make sure that:

  1. The PHPUnit tool is installed on your machine and enabled in IntelliJ IDEA.

  2. A Xdebug or Zend Debugger debugging engine is configured in the current PHP interpreter.

Install the PHP plugin

This functionality relies on the PHP plugin that should be installed and enabled in your IDE.

The plugin is available only in IntelliJ IDEA Ultimate.

  1. Press Ctrl+Alt+S to open the IDE settings and select Plugins.

  2. Switch to the Marketplace tab and use the search field to find the PHP plugin.

  3. Click Install and restart the IDE if prompted.

Configure code coverage

  1. Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Coverage.

  2. Specify coverage options on the Coverage page.

Measure code coverage

  1. Write the tests manually.

  2. Create a run configuration of the type PHPUnit.

  3. On the main toolbar, select the PHPUnit run configuration in the Run/Debug Configurations list and click the Run with Coverage button the Run with Coverage button.

  4. Review code coverage results.

Last modified: 14 July 2022