If you are familiar with the PHP environment, you may just need to read the 'Short Way' section.
If you need more help, you can follow the 'Long Way' installation guide.
Short Way for PHP Expert
- Install PHP runtime with the corresponding xdebug extensions. Version 5.2.6 or newer is required.
- Install PEAR. Version 1.8.0 or newer is required.
- Install the following PEAR packages (check the External Tools Versions section to know which versions to install):
- Install PHPUnit
- Install PHP Depend
- Install PHPMD
- Install PHP_CodeSniffer
Long Way for PHP Dummy
Recommended method for Testing the Plugin
This is the installation method recommended for your initial tests with the plugin because it requires the least effort.
Since version 1.2, all the external tools (PHP Depend, PHPMD, etc.) used by the plugin are shipped with it.
Versions of the external tools embedded as PHAR in the plugin:
Note that you will not be able to run the computation of coverage by unit tests, but only reuse existing reports, with this installation mode.
Recommended method for Production Environments
This is the recommended installation method for production environments because you can install your own version of each external tool.
You have to be logged in as an administrator to run the commands below.
- Install PHP version 5. 2.6 or newer. You can download PHP at this location and follow these installation instructions or this one and follow the instructions to install it.
Install PEAR version 1. 8.0 or newer if not included in PHP distribution. To ensure PEAR version and to upgrade it, type the following commands in command prompt:
pear version pear upgrade pear
If you, for some reason, reasons you need the latest PEAR and the commands above don't get retrieve it then , you can download http://pear.php.net/go-pear.phar and execute it with php (don't use the old go-pear without the .phar extension, it will likely fail):
Install PHPUnit from pear using the following command lines:
pear channel-discover pear.phpunit.de pear channel-discover pear.symfony-project.com pear install phpunit/PHPUnit-3X.5Y.5Z
- Install XDebug to allow code instrumentation used for instance by phpunit PHP Unit to compute coverage.
If you are running a Linux or Mac OS, you must install phpize and php headers (normally found in php dev packages like rpm php5-devel, deb php5-dev) and then compile xdebug via pecl install using the following command line:
apt-get install make apt-get install php5-dev pecl install xdebug
Another example on Fedora 18:
yum install make yum install php-devel pecl install xdebug
And then edit your $PHP_HOME/php.ini file to add the following line:
If you are running Windows, you should download the binary version matching your PHP installation from this location. And then edit your $PHP_HOME/php.ini file to add the following line:
Install PHP Depend:
pear channel-discover pear.pdepend.org pear install pdepend/PHP_Depend-1X.0Y.3Z
pear channel-discover pear.phpmd.org pear install --alldeps phpmd/PHP_PMD-1X.3Y.2Z
pear install PHP_CodeSniffer-1X.3Y.2Z
External Tools Versions
The versions listed below are the ones we use for developments and tests.
That's why, we highly recommend you to use these versions as well (even if the Sonar PHP plugin might also be compatible with other versions).
Sonar PHP Plugin