Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{iframe:src=http://updateredirect.sonarsource.orgcom/plugins/php-confluence.html|width=700|height=350300|frameborder=0}
YourDocumentation browserhas doesbeen notmoved support iframes.
{iframe}
Tip
titleLive example

If you want to see a live example of the capabilities of the PHP plugin, you can have a look at the analysis of the PHP CodeSniffer project on Nemo.

Description / Features

The plugin enables analysis of PHP source code with SonarQube. Pure PHP files and mixed HTML / PHP files can be analyzed.

Since version 2.1

You can check compliance with PHP coding standards:

  • PSR-2: the quality profile of this name contains the rules to be PSR-2 compliant.

 

Info
titleSince version 2.0

Dependency on external tools has been removed: i.e PHPDepend, PHPCodeSniffer, PHPMD, PHPUnit.

It means that the plugin relies only on the SonarQube rule engine; there is no import of external rule engine results. (PHPUnit reports can still be imported.)

Many PHPMD rules are now offered natively by the plugin. If you think that the plugin is missing some "must have" rules, you are very welcome to send your suggestions to user@sonar.codehaus.org.

...

Usage

Run an Analysis with the SonarQube Runner (Recommended method)

To run an analysis of your PHP project, use the SonarQube Runner.

...

You can also have a look at the SonarQube Runner documentation page to define a multi-module PHP project.

Run an Analysis with the other Analyzers

Maven and Ant can also be used to launch analysis on PHP projects.

Unit Tests and Code Coverage

To display unit test execution and code coverage data:

  1. Prior to the SonarQube analysis, execute your unit tests and generate a report in PHPUnit XML format (execution + code coverage).
  2. Import these reports while running the SonarQube analysis by setting the:
    •  sonar.php.coverage.reportPath property to the path to the PHPUnit code coverage report file. The path may be either absolute or relative to the project base directory.
    •  sonar.php.tests.reportPath property to the path to the PHPUnit unit test execution report file. The path may be either absolute or relative to the project base directory.

A sample project is available on GitHub that can be browsed or downloaded/projects/languages/php/php-sonar-runner-unit-tests.

Metrics

See Metrics documentation page.

Release Notes

Version 2.0

The PHP plugin does not rely anymore on external tools.

to [http://redirect.sonarsource.com/plugins/php.html].
{iframe}