Most web applications are changed and adapted quite frequently and quickly. Their environment, for example the size and the behaviour of the user base, are constantly changing. What was sufficient yesterday can be insufficient today. Especially in a web environment it is important to monitor and continuously improve the internal quality not only when developing, but also when maintaining the software.

Many of the plugins referenced (right) can be used to integrate with PHP projects, but may first need to be configured the create appropriately formatted files when working with PHP projects.

Configuring PHP Tools

The configurations below assume the use of Apache Ant as the build tool for executing PHP tools. Originally described on jenkins-php.org.

PHPUnit

The phpunit task in the build.xml assumes that an XML configuration file for PHPUnit is used to configure the following logging targets:

<logging>
 <log type="coverage-html" target="build/coverage"/>
 <log type="coverage-clover" target="build/logs/clover.xml"/>
 <log type="coverage-crap4j" target="build/logs/crap4j.xml"/>
 <log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>

You can download a sample phpunit.xml.dist and place it in your project root to get started.

More information can be found in the documentation for PHPUnit.

phpDox

The phpdox task in the build.xml assumes that an XML configuration file for phpDox is used to configure the API documentation generation:

<phpdox xmlns="http://xml.phpdox.net/config">
 <project name="name-of-project" source="src" workdir="build/phpdox">
  <collector publiconly="false">
   <include mask="*.php" />
  </collector>

  <generator output="build">
   <build engine="html" enabled="true" output="api">
    <file extension="html" />
   </build>
  </generator>
 </project>
</phpdox>

More information can be found in the documentation for phpDox.

PHP_CodeSniffer

The phpcs and phpcs-ci tasks in the build.xml assume that an XML configuration file for PHP_CodeSniffer is used to configure the coding standard:

<ruleset name="name-of-your-coding-standard">
 <description>Description of your coding standard</description>

 <rule ref="Generic.PHP.DisallowShortOpenTag"/>
 <!-- ... -->
</ruleset>

The build script assumes that the rule sets for PHP_CodeSniffer is located at build/phpcs.xml.

More information can be found in the documentation for PHP_CodeSniffer.

PHPMD

The phpmd and phpmd-ci tasks in the build.xml assume that an XML configuration file for PHPMD is used to configure the coding standard:

<ruleset name="name-of-your-coding-standard"
  xmlns="http://pmd.sf.net/ruleset/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
                      http://pmd.sf.net/ruleset_xml_schema.xsd"
  xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
  <description>Description of your coding standard</description>

  <rule ref="rulesets/codesize.xml/CyclomaticComplexity" />
  <!-- ... -->
</ruleset>

The build script assumes that the rule sets for PHPMD is located at build/phpmd.xml.

More information can be found in the documentation for PHPMD.

Much of this content was originally created by Sebastian Bergmann and hosted on Jenkins PHP.