Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save matthewkastor/3709227 to your computer and use it in GitHub Desktop.
Save matthewkastor/3709227 to your computer and use it in GitHub Desktop.
Continuous Integration for PHP on XAMPP
See: Continuous Integration for PHP on XAMPP
@ECHO OFF
GOTO weiter
:setenv
SET ANT_HOME=\xampp\apache_ant
SET JAVA_HOME=\xampp\jdk
SET CLASSPATH=
SET PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH%
SET "MIBDIRS=%~dp0php\extras\mibs"
SET "MIBDIRS=%MIBDIRS:\=/%"
SET "MYSQL_HOME=%~dp0mysql\bin"
SET "OPENSSL_CONF=%~dp0apache\bin\openssl.cnf"
SET "OPENSSL_CONF=%OPENSSL_CONF:\=/%"
SET "PHP_PEAR_SYSCONF_DIR=%~dp0php"
SET "PHPRC=%~dp0php"
SET "TMP=%~dp0tmp"
SET "PERL5LIB="
SET "Path=%~dp0;%~dp0php;%~dp0perl\site\bin;%~dp0perl\bin;%~dp0apache\bin;%~dp0mysql\bin;%~dp0FileZillaFTP;%~dp0MercuryMail;%~dp0sendmail;%~dp0webalizer;%~dp0tomcat\bin;%Path%"
GOTO :EOF
:weiter
IF "%1" EQU "setenv" (
ECHO.
ECHO Setting environment for using XAMPP for Windows.
CALL :setenv
) ELSE (
SETLOCAL
TITLE XAMPP for Windows
PROMPT %username%@%computername%$S$P$_#$S
START "" /B %COMSPEC% /K "%~f0" setenv
)
<?xml version="1.0" encoding="UTF-8"?>
<project name="myProject" default="build" basedir=".">
<property name="source" value="src"/>
<property name="phpdir" value="\xampp\php"/>
<target name="taskOrder" description="Run the tasks in the order specified here.">
<sequential>
<antcall target="clean"/>
<antcall target="phpunit"/>
<antcall target="pdepend"/>
<antcall target="phpmd"/>
<antcall target="phpcpd"/>
<antcall target="phpcs"/>
<!--antcall target="apigen"/-->
<antcall target="phpdoc"/>
<antcall target="phploc"/>
<antcall target="phpcb"/>
</sequential>
</target>
<target name="clean" description="Clean up and create artifact directories">
<delete dir="${basedir}\build\api"/>
<delete dir="${basedir}\build\code-browser"/>
<delete dir="${basedir}\build\coverage"/>
<delete dir="${basedir}\build\logs"/>
<delete dir="${basedir}\build\pdepend"/>
<delete dir="${basedir}\build\pmd"/>
<delete dir="${basedir}\build\testdox"/>
<delete dir="${basedir}\build\phpunit"/>
<!--delete dir="${basedir}\build\apigen"/-->
<mkdir dir="${basedir}\build\api"/>
<mkdir dir="${basedir}\build\code-browser"/>
<mkdir dir="${basedir}\build\coverage"/>
<mkdir dir="${basedir}\build\logs"/>
<mkdir dir="${basedir}\build\pdepend"/>
<mkdir dir="${basedir}\build\pmd"/>
<mkdir dir="${basedir}\build\testdox"/>
<mkdir dir="${basedir}\build\phpunit"/>
<!--mkdir dir="${basedir}\build\apigen"/-->
</target>
<target name="phpunit" description="Run unit tests using PHPUnit and generates junit.xml and clover.xml">
<exec executable="cmd.exe" output="${basedir}\build\phpunit\phpunit.txt">
<arg value="/c"/>
<arg value="${phpdir}\phpunit.bat"/>
<arg value="--configuration"/>
<arg value="phpunit.xml"/>
</exec>
</target>
<target name="pdepend" description="Generate jdepend.xml and software metrics charts using PHP_Depend">
<exec executable="cmd.exe">
<arg value="/c"/>
<arg value="${phpdir}\pdepend.bat"/>
<arg value="--jdepend-xml=${basedir}\build\logs\jdepend.xml"/>
<arg value="--jdepend-chart=${basedir}\build\pdepend\dependencies.svg"/>
<arg value="--overview-pyramid=${basedir}\build\pdepend\overview-pyramid.svg"/>
<arg value="${source}"/>
</exec>
</target>
<target name="phpmd" description="Generate pmd.xml using PHPMD">
<exec executable="cmd.exe">
<arg value="/c"/>
<arg value="${phpdir}\phpmd.bat"/>
<arg value="${source}"/>
<arg value="xml"/>
<arg value="codesize,design,naming,unusedcode"/>
<arg value="--strict"/>
<arg value="--reportfile"/>
<arg value="${basedir}\build\logs\pmd.xml"/>
</exec>
</target>
<target name="phpmd-html" description="Generate pmd.html using PHPMD">
<exec executable="cmd.exe">
<arg value="/c"/>
<arg value="${phpdir}\phpmd.bat"/>
<arg value="${source}"/>
<arg value="html"/>
<arg value="codesize,design,naming,unusedcode"/>
<arg value="--strict"/>
<arg value="--reportfile"/>
<arg value="${basedir}\build\pmd\pmd.html"/>
</exec>
</target>
<target name="phpcpd" description="Generate pmd-cpd.xml using PHPCPD">
<exec executable="cmd.exe">
<arg value="/c"/>
<arg value="${phpdir}\phpcpd.bat"/>
<arg value="--log-pmd"/>
<arg value="${basedir}\build\logs\pmd-cpd.xml"/>
<arg value="${source}"/>
</exec>
</target>
<target name="phploc" description="Generate phploc.csv">
<exec executable="cmd.exe">
<arg value="/c"/>
<arg value="${phpdir}\phploc.bat"/>
<arg value="--log-csv"/>
<arg value="${basedir}\build\logs\phploc.csv"/>
<arg value="${source}"/>
</exec>
</target>
<target name="phpcs" description="Generate checkstyle.xml using PHP_CodeSniffer">
<exec executable="cmd.exe">
<arg value="/c"/>
<arg value="${phpdir}\phpcs.bat"/>
<arg value="--report=checkstyle"/>
<arg value="--report-file=${basedir}\build\logs\checkstyle.xml"/>
<arg value="--tab-width=4"/>
<arg value="--standard=Zend"/>
<arg value="${source}"/>
</exec>
</target>
<!--target name="apigen" description="Generate API documentation using ApiGen">
<exec executable="cmd.exe">
<arg value="/c"/>
<arg value="${phpdir}\apigen.bat"/>
<arg value="--source"/>
<arg value="${source}"/>
<arg value="--destination"/>
<arg value="${basedir}\build\apigen"/>
<arg value="--deprecated"/>
<arg value="yes"/>
<arg value="--todo"/>
<arg value="yes"/>
<arg value="--download"/>
<arg value="yes"/>
<arg value="--report"/>
<arg value="${basedir}/build/logs/checkstyle2.xml"/>
<arg value="--wipeout"/>
<arg value="no"/>
</exec>
</target-->
<target name="phpdoc" description="Generate API documentation using PHPDocumentor">
<exec executable="cmd.exe">
<arg value="/c"/>
<arg value="${phpdir}\phpdoc.bat"/>
<arg value="--sourcecode"/>
<arg value="on"/>
<arg value="--title"/>
<arg value="${ant.project.name}"/>
<arg value="--defaultpackagename"/>
<arg value="${ant.project.name}"/>
<arg value="--defaultcategoryname"/>
<arg value="${ant.project.name}"/>
<arg value="--directory"/>
<arg value="${source}"/>
<arg value="--target"/>
<arg value="${basedir}\build\api"/>
</exec>
</target>
<target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser">
<exec executable="cmd.exe">
<arg value="/c"/>
<arg value="${phpdir}\phpcb.bat"/>
<arg value="--log"/>
<arg value="${basedir}\build\logs"/>
<arg value="--source"/>
<arg value="${source}"/>
<arg value="--output"/>
<arg value="${basedir}\build\code-browser"/>
</exec>
</target>
<target name="build" depends="taskOrder"/>
</project>
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description>&lt;embed height=&quot;300&quot; src=&quot;ws/build/pdepend/overview-pyramid.svg&quot; type=&quot;image/svg+xml&quot; width=&quot;500&quot;&gt;&lt;/embed&gt;&#xd;
&lt;embed height=&quot;300&quot; src=&quot;ws/build/pdepend/dependencies.svg&quot; type=&quot;image/svg+xml&quot; width=&quot;500&quot;&gt;&lt;/embed&gt;</description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers class="vector"/>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Ant>
<targets></targets>
<antName>ant</antName>
</hudson.tasks.Ant>
</builders>
<publishers>
<hudson.plugins.checkstyle.CheckStylePublisher>
<healthy></healthy>
<unHealthy></unHealthy>
<thresholdLimit>low</thresholdLimit>
<pluginName>[CHECKSTYLE] </pluginName>
<defaultEncoding></defaultEncoding>
<canRunOnFailed>true</canRunOnFailed>
<useDeltaValues>false</useDeltaValues>
<thresholds>
<unstableTotalAll></unstableTotalAll>
<unstableTotalHigh></unstableTotalHigh>
<unstableTotalNormal></unstableTotalNormal>
<unstableTotalLow></unstableTotalLow>
<unstableNewAll></unstableNewAll>
<unstableNewHigh></unstableNewHigh>
<unstableNewNormal></unstableNewNormal>
<unstableNewLow></unstableNewLow>
<failedTotalAll></failedTotalAll>
<failedTotalHigh></failedTotalHigh>
<failedTotalNormal></failedTotalNormal>
<failedTotalLow></failedTotalLow>
<failedNewAll></failedNewAll>
<failedNewHigh></failedNewHigh>
<failedNewNormal></failedNewNormal>
<failedNewLow></failedNewLow>
</thresholds>
<shouldDetectModules>false</shouldDetectModules>
<dontComputeNew>false</dontComputeNew>
<pattern>build/logs/checkstyle.xml</pattern>
</hudson.plugins.checkstyle.CheckStylePublisher>
<hudson.plugins.pmd.PmdPublisher>
<healthy></healthy>
<unHealthy></unHealthy>
<thresholdLimit>low</thresholdLimit>
<pluginName>[PMD] </pluginName>
<defaultEncoding></defaultEncoding>
<canRunOnFailed>true</canRunOnFailed>
<useDeltaValues>false</useDeltaValues>
<thresholds>
<unstableTotalAll></unstableTotalAll>
<unstableTotalHigh></unstableTotalHigh>
<unstableTotalNormal></unstableTotalNormal>
<unstableTotalLow></unstableTotalLow>
<unstableNewAll></unstableNewAll>
<unstableNewHigh></unstableNewHigh>
<unstableNewNormal></unstableNewNormal>
<unstableNewLow></unstableNewLow>
<failedTotalAll></failedTotalAll>
<failedTotalHigh></failedTotalHigh>
<failedTotalNormal></failedTotalNormal>
<failedTotalLow></failedTotalLow>
<failedNewAll></failedNewAll>
<failedNewHigh></failedNewHigh>
<failedNewNormal></failedNewNormal>
<failedNewLow></failedNewLow>
</thresholds>
<shouldDetectModules>false</shouldDetectModules>
<dontComputeNew>false</dontComputeNew>
<pattern>build/logs/pmd.xml</pattern>
</hudson.plugins.pmd.PmdPublisher>
<hudson.plugins.dry.DryPublisher>
<healthy></healthy>
<unHealthy></unHealthy>
<thresholdLimit>low</thresholdLimit>
<pluginName>[DRY] </pluginName>
<defaultEncoding></defaultEncoding>
<canRunOnFailed>true</canRunOnFailed>
<useDeltaValues>false</useDeltaValues>
<thresholds>
<unstableTotalAll></unstableTotalAll>
<unstableTotalHigh></unstableTotalHigh>
<unstableTotalNormal></unstableTotalNormal>
<unstableTotalLow></unstableTotalLow>
<unstableNewAll></unstableNewAll>
<unstableNewHigh></unstableNewHigh>
<unstableNewNormal></unstableNewNormal>
<unstableNewLow></unstableNewLow>
<failedTotalAll></failedTotalAll>
<failedTotalHigh></failedTotalHigh>
<failedTotalNormal></failedTotalNormal>
<failedTotalLow></failedTotalLow>
<failedNewAll></failedNewAll>
<failedNewHigh></failedNewHigh>
<failedNewNormal></failedNewNormal>
<failedNewLow></failedNewLow>
</thresholds>
<shouldDetectModules>false</shouldDetectModules>
<dontComputeNew>false</dontComputeNew>
<pattern>build/logs/pmd-cpd.xml</pattern>
<highThreshold>50</highThreshold>
<normalThreshold>25</normalThreshold>
</hudson.plugins.dry.DryPublisher>
<hudson.plugins.plot.PlotPublisher>
<plots>
<hudson.plugins.plot.Plot>
<title>A - Lines of code</title>
<yaxis>Lines of Code</yaxis>
<series>
<hudson.plugins.plot.CSVSeries>
<file>build/logs/phploc.csv</file>
<label></label>
<fileType>csv</fileType>
<strExclusionSet>
<string>Lines of Code (LOC)</string>
<string>Comment Lines of Code (CLOC)</string>
<string>Non-Comment Lines of Code (NCLOC)</string>
</strExclusionSet>
<inclusionFlag>INCLUDE_BY_STRING</inclusionFlag>
<exclusionValues>Lines of Code (LOC),Comment Lines of Code (CLOC),Non-Comment Lines of Code (NCLOC)</exclusionValues>
<url></url>
<displayTableFlag>false</displayTableFlag>
</hudson.plugins.plot.CSVSeries>
</series>
<group>phploc</group>
<numBuilds>100</numBuilds>
<csvFileName>123.csv</csvFileName>
<csvLastModification>0</csvLastModification>
<style>line</style>
<useDescr>false</useDescr>
</hudson.plugins.plot.Plot>
<hudson.plugins.plot.Plot>
<title>B - Structures</title>
<yaxis>Count</yaxis>
<series>
<hudson.plugins.plot.CSVSeries>
<file>build/logs/phploc.csv</file>
<label></label>
<fileType>csv</fileType>
<strExclusionSet>
<string>Functions</string>
<string>Classes</string>
<string>Namespaces</string>
<string>Files</string>
<string>Directories</string>
<string>Methods</string>
<string>Interfaces</string>
<string>Constants</string>
<string>Anonymous Functions</string>
</strExclusionSet>
<inclusionFlag>INCLUDE_BY_STRING</inclusionFlag>
<exclusionValues>Directories,Files,Namespaces,Interfaces,Classes,Methods,Functions,Anonymous Functions,Constants</exclusionValues>
<url></url>
<displayTableFlag>false</displayTableFlag>
</hudson.plugins.plot.CSVSeries>
</series>
<group>phploc</group>
<numBuilds>100</numBuilds>
<csvFileName>1107599928.csv</csvFileName>
<csvLastModification>0</csvLastModification>
<style>line</style>
<useDescr>false</useDescr>
</hudson.plugins.plot.Plot>
<hudson.plugins.plot.Plot>
<title>G - Average Length</title>
<yaxis>Average Non-Comment Lines of Code</yaxis>
<series>
<hudson.plugins.plot.CSVSeries>
<file>build/logs/phploc.csv</file>
<label></label>
<fileType>csv</fileType>
<strExclusionSet>
<string>Average Method Length (NCLOC)</string>
<string>Average Class Length (NCLOC)</string>
</strExclusionSet>
<inclusionFlag>INCLUDE_BY_STRING</inclusionFlag>
<exclusionValues>Average Class Length (NCLOC),Average Method Length (NCLOC)</exclusionValues>
<url></url>
<displayTableFlag>false</displayTableFlag>
</hudson.plugins.plot.CSVSeries>
</series>
<group>phploc</group>
<numBuilds>100</numBuilds>
<csvFileName>523405415.csv</csvFileName>
<csvLastModification>0</csvLastModification>
<style>line</style>
<useDescr>false</useDescr>
</hudson.plugins.plot.Plot>
<hudson.plugins.plot.Plot>
<title>H - Relative Cyclomatic Complexity</title>
<yaxis>Cyclomatic Complexity by Strcuture</yaxis>
<series>
<hudson.plugins.plot.CSVSeries>
<file>build/logs/phploc.csv</file>
<label></label>
<fileType>csv</fileType>
<strExclusionSet>
<string>Cyclomatic Complexity / Lines of Code</string>
<string>Cyclomatic Complexity / Number of Methods</string>
</strExclusionSet>
<inclusionFlag>INCLUDE_BY_STRING</inclusionFlag>
<exclusionValues>Cyclomatic Complexity / Lines of Code,Cyclomatic Complexity / Number of Methods</exclusionValues>
<url></url>
<displayTableFlag>false</displayTableFlag>
</hudson.plugins.plot.CSVSeries>
</series>
<group>phploc</group>
<numBuilds>100</numBuilds>
<csvFileName>186376189.csv</csvFileName>
<csvLastModification>0</csvLastModification>
<style>line</style>
<useDescr>false</useDescr>
</hudson.plugins.plot.Plot>
<hudson.plugins.plot.Plot>
<title>D - Types of Classes</title>
<yaxis>Count</yaxis>
<series>
<hudson.plugins.plot.CSVSeries>
<file>build/logs/phploc.csv</file>
<label></label>
<fileType>csv</fileType>
<strExclusionSet>
<string>Abstract Classes</string>
<string>Classes</string>
<string>Concrete Classes</string>
</strExclusionSet>
<inclusionFlag>INCLUDE_BY_STRING</inclusionFlag>
<exclusionValues>Classes,Abstract Classes,Concrete Classes</exclusionValues>
<url></url>
<displayTableFlag>false</displayTableFlag>
</hudson.plugins.plot.CSVSeries>
</series>
<group>phploc</group>
<numBuilds>100</numBuilds>
<csvFileName>594356163.csv</csvFileName>
<csvLastModification>0</csvLastModification>
<style>line</style>
<useDescr>false</useDescr>
</hudson.plugins.plot.Plot>
<hudson.plugins.plot.Plot>
<title>E - Types of Methods</title>
<yaxis>Count</yaxis>
<series>
<hudson.plugins.plot.CSVSeries>
<file>build/logs/phploc.csv</file>
<label></label>
<fileType>csv</fileType>
<strExclusionSet>
<string>Methods</string>
<string>Static Methods</string>
<string>Non-Static Methods</string>
<string>Public Methods</string>
<string>Non-Public Methods</string>
</strExclusionSet>
<inclusionFlag>INCLUDE_BY_STRING</inclusionFlag>
<exclusionValues>Methods,Non-Static Methods,Static Methods,Public Methods,Non-Public Methods</exclusionValues>
<url></url>
<displayTableFlag>false</displayTableFlag>
</hudson.plugins.plot.CSVSeries>
</series>
<group>phploc</group>
<numBuilds>100</numBuilds>
<csvFileName>1019987862.csv</csvFileName>
<csvLastModification>0</csvLastModification>
<style>line</style>
<useDescr>false</useDescr>
</hudson.plugins.plot.Plot>
<hudson.plugins.plot.Plot>
<title>F - Types of Constants</title>
<yaxis>Count</yaxis>
<series>
<hudson.plugins.plot.CSVSeries>
<file>build/logs/phploc.csv</file>
<label></label>
<fileType>csv</fileType>
<strExclusionSet>
<string>Class Constants</string>
<string>Global Constants</string>
<string>Constants</string>
</strExclusionSet>
<inclusionFlag>INCLUDE_BY_STRING</inclusionFlag>
<exclusionValues>Constants,Global Constants,Class Constants</exclusionValues>
<url></url>
<displayTableFlag>false</displayTableFlag>
</hudson.plugins.plot.CSVSeries>
</series>
<group>phploc</group>
<numBuilds>100</numBuilds>
<csvFileName>217648577.csv</csvFileName>
<csvLastModification>0</csvLastModification>
<style>line</style>
<useDescr>false</useDescr>
</hudson.plugins.plot.Plot>
<hudson.plugins.plot.Plot>
<title>C - Testing</title>
<yaxis>Count</yaxis>
<series>
<hudson.plugins.plot.CSVSeries>
<file>build/logs/phploc.csv</file>
<label></label>
<fileType>csv</fileType>
<strExclusionSet>
<string>Functions</string>
<string>Classes</string>
<string>Methods</string>
<string>Test Clases</string>
<string>Test Methods</string>
</strExclusionSet>
<inclusionFlag>INCLUDE_BY_STRING</inclusionFlag>
<exclusionValues>Classes,Methods,Functions,Test Clases,Test Methods</exclusionValues>
<url></url>
<displayTableFlag>false</displayTableFlag>
</hudson.plugins.plot.CSVSeries>
</series>
<group>phploc</group>
<numBuilds>100</numBuilds>
<csvFileName>174807245.csv</csvFileName>
<csvLastModification>0</csvLastModification>
<style>line</style>
<useDescr>false</useDescr>
</hudson.plugins.plot.Plot>
</plots>
</hudson.plugins.plot.PlotPublisher>
<org.jenkinsci.plugins.cloverphp.CloverPublisher>
<publishHtmlReport>true</publishHtmlReport>
<reportDir>build/coverage</reportDir>
<xmlLocation>build/logs/clover.xml</xmlLocation>
<disableArchiving>false</disableArchiving>
<healthyTarget>
<methodCoverage>70</methodCoverage>
<statementCoverage>80</statementCoverage>
</healthyTarget>
<unhealthyTarget/>
<failingTarget/>
</org.jenkinsci.plugins.cloverphp.CloverPublisher>
<htmlpublisher.HtmlPublisher>
<reportTargets>
<htmlpublisher.HtmlPublisherTarget>
<reportName>API Documentation</reportName>
<reportDir>build/api</reportDir>
<reportFiles>index.html</reportFiles>
<keepAll>true</keepAll>
<wrapperName>htmlpublisher-wrapper.html</wrapperName>
</htmlpublisher.HtmlPublisherTarget>
<htmlpublisher.HtmlPublisherTarget>
<reportName>Code Browser</reportName>
<reportDir>build/code-browser</reportDir>
<reportFiles>index.html</reportFiles>
<keepAll>true</keepAll>
<wrapperName>htmlpublisher-wrapper.html</wrapperName>
</htmlpublisher.HtmlPublisherTarget>
</reportTargets>
</htmlpublisher.HtmlPublisher>
<org.jenkinsci.plugins.xunit.XUnitPublisher>
<types>
<PHPUnitJunitHudsonTestType>
<pattern>build/logs/junit.xml</pattern>
<faildedIfNotNew>true</faildedIfNotNew>
<deleteOutputFiles>true</deleteOutputFiles>
<stopProcessingIfError>true</stopProcessingIfError>
</PHPUnitJunitHudsonTestType>
</types>
<thresholds>
<org.jenkinsci.plugins.xunit.threshold.FailedThreshold>
<unstableThreshold>0</unstableThreshold>
<unstableNewThreshold>0</unstableNewThreshold>
<failureThreshold>0</failureThreshold>
<failureNewThreshold>0</failureNewThreshold>
</org.jenkinsci.plugins.xunit.threshold.FailedThreshold>
<org.jenkinsci.plugins.xunit.threshold.SkippedThreshold>
<unstableThreshold>0</unstableThreshold>
<unstableNewThreshold>0</unstableNewThreshold>
<failureThreshold>0</failureThreshold>
<failureNewThreshold>0</failureNewThreshold>
</org.jenkinsci.plugins.xunit.threshold.SkippedThreshold>
</thresholds>
</org.jenkinsci.plugins.xunit.XUnitPublisher>
<hudson.plugins.jdepend.JDependRecorder>
<configuredJDependFile>build/logs/jdepend.xml</configuredJDependFile>
</hudson.plugins.jdepend.JDependRecorder>
<hudson.plugins.violations.ViolationsPublisher>
<config>
<suppressions class="tree-set">
<no-comparator/>
</suppressions>
<typeConfigs>
<no-comparator/>
<entry>
<string>checkstyle</string>
<hudson.plugins.violations.TypeConfig>
<type>checkstyle</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern>build/logs/checkstyle.xml</pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>codenarc</string>
<hudson.plugins.violations.TypeConfig>
<type>codenarc</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern></pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>cpd</string>
<hudson.plugins.violations.TypeConfig>
<type>cpd</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern>build/logs/pmd-cpd.xml</pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>cpplint</string>
<hudson.plugins.violations.TypeConfig>
<type>cpplint</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern></pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>csslint</string>
<hudson.plugins.violations.TypeConfig>
<type>csslint</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern></pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>findbugs</string>
<hudson.plugins.violations.TypeConfig>
<type>findbugs</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern></pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>fxcop</string>
<hudson.plugins.violations.TypeConfig>
<type>fxcop</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern></pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>gendarme</string>
<hudson.plugins.violations.TypeConfig>
<type>gendarme</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern></pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>jcreport</string>
<hudson.plugins.violations.TypeConfig>
<type>jcreport</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern></pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>jslint</string>
<hudson.plugins.violations.TypeConfig>
<type>jslint</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern></pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>pep8</string>
<hudson.plugins.violations.TypeConfig>
<type>pep8</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern></pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>pmd</string>
<hudson.plugins.violations.TypeConfig>
<type>pmd</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern>build/logs/pmd.xml</pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>pylint</string>
<hudson.plugins.violations.TypeConfig>
<type>pylint</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern></pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>simian</string>
<hudson.plugins.violations.TypeConfig>
<type>simian</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern></pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
<entry>
<string>stylecop</string>
<hudson.plugins.violations.TypeConfig>
<type>stylecop</type>
<min>10</min>
<max>999</max>
<unstable>999</unstable>
<usePattern>false</usePattern>
<pattern></pattern>
</hudson.plugins.violations.TypeConfig>
</entry>
</typeConfigs>
<limit>100</limit>
<sourcePathPattern></sourcePathPattern>
<fauxProjectPath></fauxProjectPath>
<encoding>UTF-8</encoding>
</config>
</hudson.plugins.violations.ViolationsPublisher>
</publishers>
<buildWrappers/>
</project>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en-us"
xml:lang="en-us">
<head>
<meta http-equiv="content-type"
content="text/html; charset=utf-8" />
<title>
Continuous Integration for PHP on XAMPP
</title>
<meta name="author"
content="Kastor" />
</head>
<body style="direction: ltr;">
<h1>
<a class="mozTocH1"
name="mozTocId251604"
id="mozTocId251604"></a> Continuous Integration for PHP on XAMPP
</h1>
<p>
What follows is a long list of tools, configuration settings, and instructions for setting up a continuous integration server for PHP on XAMPP.
</p>
<!-- more -->
<h2>
<a class="mozTocH2"
name="mozTocId552879"
id="mozTocId552879"></a> Contents
</h2>
<ol id="mozToc">
<!--mozToc h1 1 h2 2 h3 3 h4 4 h5 5 h6 6-->
<li>
<a href="#mozTocId251604">Continuous Integration for PHP on XAMPP</a>
<ol>
<li>
<a href="#mozTocId552879">Contents</a>
</li>
<li>
<a href="#mozTocId174439">Context</a>
</li>
<li>
<a href="#mozTocId297382">Mandatory Gibberish</a>
<ol>
<li>
<a href="#mozTocId615397">Xdebug</a>
</li>
<li>
<a href="#mozTocId944084">Java Developer Kit</a>
</li>
<li>
<a href="#mozTocId146417">Jenkins</a>
</li>
<li>
<a href="#mozTocId47469">Apache Ant</a>
</li>
<li>
<a href="#mozTocId418459">PHP Project Wizard</a>
</li>
<li>
<a href="#mozTocId286113">Template for Jenkins Jobs for PHP Projects</a>
</li>
</ol>
</li>
<li>
<a href="#mozTocId922437">Mashing it All Together</a>
<ol>
<li>
<a href="#mozTocId157110">Explanation of downloaded files</a>
<ol>
<li>
<a href="#mozTocId582995">altered_xampp_shell.bat</a>
</li>
<li>
<a href="#mozTocId802512">jenkins.bat</a>
</li>
<li>
<a href="#mozTocId464234">build.xml</a>
</li>
<li>
<a href="#mozTocId286244">config.xml</a>
</li>
<li>
<a href="#mozTocId886837">netbeans.conf</a>
</li>
</ol>
</li>
<li>
<a href="#mozTocId815534">Jenkins Settings</a>
<ol>
<li>
<a href="#mozTocId991239">Changing the Workspace Directory</a>
</li>
<li>
<a href="#mozTocId797620">Set JDK and Ant Locations</a>
</li>
</ol>
</li>
<li>
<a href="#mozTocId154519">Directory Structure of PHP Projects</a>
</li>
<li>
<a href="#mozTocId639924">Adding Netbeans</a>
</li>
<li>
<a href="#mozTocId117889">Adding Subversion</a>
</li>
<li>
<a href="#mozTocId380053">Embedded Gist</a>
</li>
</ol>
</li>
</ol>
</li>
</ol>
<!--more-->
<h2>
<a class="mozTocH2"
name="mozTocId174439"
id="mozTocId174439"></a> Context
</h2>
<pre space="preserve">
<span style="font-weight: bold;">DATE /T</span>
2012/01/29
<span style="font-weight: bold;">php -v</span>
PHP 5.3.8 (cli) (built: Aug 23 2011 11:50:20)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans
<span style="font-weight: bold;">Jenkins</span>
Java Web Archive (.war)
Latest and Greatest 1.449
<span style="font-weight: bold;">ant -version</span>
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
<span style="font-weight: bold;">ppw --version</span>
PHP Project Wizard (PPW) 1.0.4 by Sebastian Bergmann.
<span style="font-weight: bold;">java -version</span>
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) Client VM (build 22.0-b10, mixed mode, sharing)
<span style="font-weight: bold;">Netbeans</span>
<span style="font-style: italic;">Product Version:</span> NetBeans IDE 7.1 (Build 201112071828)
<span style="font-style: italic;">Java:</span> 1.7.0_02; Java HotSpot(TM) Client VM 22.0-b10
<span style="font-style: italic;">System:</span> Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
<span style="font-style: italic;">User directory:</span> C:\xampp\userDirectories\netbeans\7.1\default
<span style="font-style: italic;">Cache directory:</span> C:\xampp\userDirectories\netbeans\7.1\default\var\cache
</pre>
<h2>
<a class="mozTocH2"
name="mozTocId297382"
id="mozTocId297382"></a> Mandatory Gibberish
</h2>
<h3>
<a class="mozTocH3"
name="mozTocId615397"
id="mozTocId615397"></a> Xdebug
</h3>
<p>
In order for the tools I'm talking about to fully function you'll need to have Xdebug installed and enabled. You'll find documentation and installation instructions at <a href="http://xdebug.org/">http://xdebug.org/</a> Also, you'll be able to download the binary file for windows. Check the site for the latest version.
</p>
<h3>
<a class="mozTocH3"
name="mozTocId944084"
id="mozTocId944084"></a> Java Developer Kit
</h3>
<p>
The Java Developer Kit contains additional tools that are needed by many advanced tools. There are many tools that won't work with the Java Runtime Environment because they're developer applications and need developers tools. Download the JDK from <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">http://www.oracle.com/technetwork/java/javase/downloads/index.html</a>
</p>
<h3>
<a class="mozTocH3"
name="mozTocId146417"
id="mozTocId146417"></a> Jenkins
</h3>
<p>
Jenkins is a continuous integration server. By itself, Jenkins doesnt do much. Think of it as a container for other tools. The tools you integrate with it will have a handy interface so you can check the state of your code at any time. The idea is to make it easy (non-tedious) to analyze your project and find errors as they're written, instead of after they've been buried under hours or days worth of work. It takes a bit of patience, and if you're not familiar with the tools you're integrating into Jenkins it can be frustrating but, in the end it's worth the effort. Download Jenkins from <a href="http://jenkins-ci.org/">http://jenkins-ci.org/</a>
</p>
<h3>
<a class="mozTocH3"
name="mozTocId47469"
id="mozTocId47469"></a> Apache Ant
</h3>
<p>
Apache Ant is a build tool. Instead of writing batch files, you write xml files that define tasks and use ant to run those tasks. Once you've got the gist of the xml files it's easy to create new tasks. Many IDE's and other tools have Ant support built in, it's really a great tool to have and know how to use. Download Ant from <a href="http://ant.apache.org/bindownload.cgi">http://ant.apache.org/bindownload.cgi</a>
</p>
<h3>
<a class="mozTocH3"
name="mozTocId418459"
id="mozTocId418459"></a> PHP Project Wizard
</h3>
<p>
On the site <a href="http://jenkins-php.org/">http://jenkins-php.org/</a>, mentioned below, there are instructions for setting up Jenkins Jobs for PHP Projects. Near the bottom of the page, the PHP Project Wizard is mentioned. While it did not work for me without doing quite a bit of editing to the files it created, it did give me a start in the right direction. You don't really need to install it, but it may benefit you to run it at least once and look at the generated files. PPW is installed through Pear, you can read more about the project and get the latest instructions here <a href="https://github.com/sebastianbergmann/php-project-wizard">https://github.com/sebastianbergmann/php-project-wizard</a>
</p>
<h3>
<a class="mozTocH3"
name="mozTocId286113"
id="mozTocId286113"></a> Template for Jenkins Jobs for PHP Projects
</h3>
<p>
On the site <a href="http://jenkins-php.org/">http://jenkins-php.org/</a> there are instructions for setting up Jenkins. Everything seems straightforward when you're reading the directions but, if you're trying to do it on windows you'll fail. There are a few differences in the way you'll have to write the build.xml file in order for Ant to be able to do it's job on windows. There are a few differences in how Jenkins is set up to work with XAMPP. Finally, there are a few batch files to write to get things started up properly. I'll try to provide good information that is easy to understand but, we're about to start juggling six balls in one hand here. Once it's all set up the juggling will be done in the background and all that will be left to do is click a link and see results, it's worth putting in the work here. So, open <a href="http://jenkins-php.org/">http://jenkins-php.org/</a> in another tab, follow the directions, and edit the steps as outlined below in "Mashing it all together".
</p>
<h2>
<a class="mozTocH2"
name="mozTocId922437"
id="mozTocId922437"></a> Mashing it All Together
</h2>
<p>
Download the files located at <a href="https://gist.github.com/gists/1701198/download">https://gist.github.com/gists/1701198/download</a>. There are other ways to get this gist:
</p>
<p>
gist: 1701198 Description: Continuous Integration for PHP on XAMPP Public Clone URL: git://gist.github.com/1701198.git
</p>
<h3>
<a class="mozTocH3"
name="mozTocId157110"
id="mozTocId157110"></a> Explanation of downloaded files
</h3>
<h4>
<a class="mozTocH4"
name="mozTocId582995"
id="mozTocId582995"></a> altered_xampp_shell.bat
</h4>
<p>
added the following lines
</p>
<pre space="preserve">
SET ANT_HOME=\xampp\apache_ant
SET JAVA_HOME=\xampp\jdk
SET CLASSPATH=
SET PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH%
</pre>
<p>
Apache Ant requires the environment variable ANT_HOME. The installation instructions for Apache Ant advise setting the CLASSPATH as empty. Many Java programs require the environment variable JAVA_HOME. Adding ANT_HOME and JAVA_HOME to the path is necessary so that Ant and the JDK will function from the command line. Note that this does not permanently alter the PATH and is only effective per instance of the command interpreter invoked from this batch file. If you attempt to run a batch file from the prompt generated by this batch file and you receive errors or odd behavior, try CALL otherfile.bat.
</p>
<p>
From these lines it is obvious that the files for Ant are to be placed in \xampp\apache_ant. The folder apache_ant will contain all the files from the Ant distribution.
</p>
<pre space="preserve">
\XAMPP\apache_ant
├───bin
├───docs
├───etc
└───lib
</pre>
<p>
From these lines it is obvious that the files from the JDK are to be placed in \xampp\jdk
</p>
<pre space="preserve">
\XAMP\jdk
├───bin
├───db
├───include
├───jre
└───lib
</pre>
<h4>
<a class="mozTocH4"
name="mozTocId802512"
id="mozTocId802512"></a> jenkins.bat
</h4>
<pre space="preserve">
@echo off
TITLE Jenkins Server
set Path=\xampp\jdk\bin;%Path%
set JENKINS_HOME=\xampp\Jenkins\Home
java -jar jenkins.war
</pre>
<p>
Adds Java Developer Kit's bin file to the path so the war file will run. Sets JENKINS_HOME directory as a subfolder of Jenkins directory in xampp. Initially you'll only have the war file and this batch file in the Jenkins directory. Once you run the bat file Java will extract the war file to the Jenkins directory. You should always start Jenkins using the batch file so you know that your data is being written to the Home directory.
</p>
<pre space="preserve">
\xampp
├───apache_ant
├───jdk
├───Jenkins
│ ├───jenkins.bat
│ └───jenkins.war
└───php
</pre>
<h4>
<a class="mozTocH4"
name="mozTocId464234"
id="mozTocId464234"></a> build.xml
</h4>
<p>
This is the Ant build file to use instead of the one you can copy or download from <a href="http://jenkins-php.org/">http://jenkins-php.org/</a>. Place it in the root of your project.
</p>
<pre space="preserve">
\xampp\htdocs\myProject\build.xml
</pre>
<h4>
<a class="mozTocH4"
name="mozTocId286244"
id="mozTocId286244"></a> config.xml
</h4>
<p>
This file is a default setup for jobs. When you get to the section of <a href="http://jenkins-php.org/">http://jenkins-php.org/</a> labeled "Using the Job Template", download the job template "php-template" and replace the config.xml file in it with this one.
</p>
<pre space="preserve">
\xampp\Jenkins\Home\jobs\php-template\config.xml
</pre>
<h4>
<a class="mozTocH4"
name="mozTocId886837"
id="mozTocId886837"></a> netbeans.conf
</h4>
<p>
This file is for Netbeans. Netbeans comes with built in support for phpunit and svn. They've also got excellent documentation on how to set it up. Basically you set the general options for Netbeans by telling it the location of phpunit.bat and svn.exe. Then, in your project settings you set the tests folder as your "tests directory". It's that simple. You right click on a file and there are options to run the test or have phpunit report on code coverage. You can also run all tests and generate code coverage reports on the entire project. The code coverage report displays a percentage of code covered for each file and also highlights the source code to show what is covered and what is not covered. It's very handy stuff. The subversion support is good, you have to create the repository using a single command on the command line, but after that you can do pretty much everything from the IDE. Like I said, their documentation is excellent, if you want to use Netbeans to take advantage of these features, I've included this configuration file to get you up and running a bit faster. Place this configuration file in \xampp\netbeans\etc
</p>
<p>
The version of Netbeans to download is 7.1. <a href="http://netbeans.org/downloads/">On the download page</a>, be sure to change the platform to "OS Independent Zip".
</p>
<p>
Create the directory structure \xampp\userDirectories\netbeans\7.1\default\, or change the setting in this configuration file and create the user settings folder somewhere else.
</p>
<h3>
<a class="mozTocH3"
name="mozTocId815534"
id="mozTocId815534"></a> Jenkins Settings
</h3>
<h4>
<a class="mozTocH4"
name="mozTocId991239"
id="mozTocId991239"></a> Changing the Workspace Directory
</h4>
<p>
In order to have your project files located at \xampp\htdocs\myProject, it is necessary to change a configuration option in Jenkins. Otherwise, your project will have to be located at \xampp\Jenkins\Home\workspace\myProject. Having the project located there could be problematic for your IDE or other tools you may want to use.
</p>
<p>
The setting to change the default workspace directory is located at <a href="http://localhost:8080/configure">http://localhost:8080/configure</a>. At the top of the page you'll see the read only setting "Home directory". Just below that setting and all the way to the right of the page there is a button labeled "Advanced", click it. Two new configuration options will now be exposed, set them to match the following:
</p>
<p style="margin-left: 40px;">
Workspace Root Directory /xampp/htdocs/${ITEM_FULLNAME}
</p>
<p style="margin-left: 40px;">
Build Record Root Directory ${ITEM_ROOTDIR}/builds
</p>
<h4>
<a class="mozTocH4"
name="mozTocId797620"
id="mozTocId797620"></a> Set JDK and Ant Locations
</h4>
<p>
Scroll down the page until you get to the section labeled "JDK". Click "Add JDK" fill in the name as jdk and the JAVA_HOME as \xampp\jdk\
</p>
<p>
Scroll down the page until you get to the section labeled "Ant". Click "Add Ant" fill in the name as ant and the ANT_HOME as \xampp\apache_ant
</p>
<p>
Click the save button floating at the bottom left hand side of the screen.
</p>
<h3>
<a class="mozTocH3"
name="mozTocId154519"
id="mozTocId154519"></a> Directory Structure of PHP Projects
</h3>
<p>
The directory structure for PHP projects remains the same as is explained on <a href="http://jenkins-php.org/">http://jenkins-php.org/</a> however, I thought it may be helpful if I lay it out visually here.
</p>
<pre space="preserve">
\XAMPP\HTDOCS\myProject
├───build
├───src
└───tests
</pre>
<p>
Obviously, the src folder will contain the files and directories of your project. The tests folder will contain your PHPUnit tests. The build folder will be populated with files and folders generated by the Ant build script and Jenkins. If you want to change the directory structure you'll have to find the relevant settings in build.xml, config.xml, or any other file which sets up an expectation of finding this particular directory structure.
</p>
<h3>
<a class="mozTocH3"
name="mozTocId639924"
id="mozTocId639924"></a> Adding Netbeans
</h3>
<p>
<a href="http://netbeans.org/downloads/">Download the latest version of the zip archive</a>. You can get it by changing the "platform" option to "OS Independent Zip". You can chose the package with built in PHP support or you can chose one that doesn't have it built in and try figuring out what plugins you have to download. . . After you download the zip file extract it and put the contents into a folder at \xampp\netbeans\
</p>
<pre space="preserve">
\XAMPP\NETBEANS
├───bin
├───etc
├───harness
│ ├───antlib
│ ├───config
│ │ └───Modules
</pre>
<h3>
<a class="mozTocH3"
name="mozTocId117889"
id="mozTocId117889"></a> Adding Subversion
</h3>
<p>
Download the zip version of the windows binaries from <a href="http://alagazam.net/">http://alagazam.net/</a> and unzip it to \xampp\subversion The command line client will work right away. If you want, you could add \xampp\subversion\bin to the path in altered_xampp_shell.bat and have easy access to it from anywhere within the xampp shell. You can also integrate subversion into the build process using either Ant or Jenkins, depending on what you want to do and when. Creating a repository is as easy as running the command:
</p>
<pre space="preserve">
\xampp\subversion\bin\svnadmin.exe create \xampp\repository
</pre>
<h3>
<a class="mozTocH3"
name="mozTocId380053"
id="mozTocId380053"></a>Embedded Gist
</h3>
<p>
Clone it: <code>git clone git://gist.github.com/3709227.git gist-3709227</code>
</p>
<script src="https://gist.github.com/3709227.js"
type="text/javascript">
</script>
</body>
</html>
@echo off
TITLE Jenkins Server
set Path=\xampp\jdk\bin;%Path%
set JENKINS_HOME=\xampp\Jenkins\Home
java -jar jenkins.war
# ${HOME} will be replaced by JVM user.home system property
netbeans_default_userdir="\xampp\userDirectories\netbeans\7.1\default"
# Options used by NetBeans launcher by default, can be overridden by explicit
# command line switches:
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true"
# Note that default -Xmx and -XX:MaxPermSize are selected for you automatically.
# You can find these values in var/log/messages.log file in your userdir.
# The automatically selected value can be overridden by specifying -J-Xmx or
# -J-XX:MaxPermSize= here or on the command line.
# If you specify the heap size (-Xmx) explicitly, you may also want to enable
# Concurrent Mark & Sweep garbage collector. In such case add the following
# options to the netbeans_default_options:
# -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled
# (see http://wiki.netbeans.org/FaqGCPauses)
# Default location of JDK, can be overridden by using --jdkhome <dir>:
netbeans_jdkhome="\xampp\jdk"
# Additional module clusters, using ${path.separator} (';' on Windows or ':' on Unix):
#netbeans_extraclusters="/absolute/path/to/cluster1:/absolute/path/to/cluster2"
# If you have some problems with detect of proxy settings, you may want to enable
# detect the proxy settings provided by JDK5 or higher.
# In such case add -J-Djava.net.useSystemProxies=true to the netbeans_default_options.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment