Skip to content

Instantly share code, notes, and snippets.

@michaelbunch
Last active August 29, 2015 14:02
Show Gist options
  • Save michaelbunch/660fee3780eff32c213c to your computer and use it in GitHub Desktop.
Save michaelbunch/660fee3780eff32c213c to your computer and use it in GitHub Desktop.
Apache Ant build.xml file for validating PHP projects
<?xml version="1.0" encoding="UTF-8"?>
<project name="ProjectChecker" default="build" basedir=".">
<target name="build" depends="tools,testing" />
<target name="tools" depends="tools.phplint,tools.phpcs,tools.phpmd" description="Run code examination tools" />
<target name="tools.phplint" description="Check code with PHP Lint option">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}/app">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
<target name="tools.phpcs" description="Check code with PHP Code Sniffer">
<exec executable="phpcs">
<arg value="-n" />
<arg value="--ignore=vendor/*,app/views/*,app/storage/*" />
<arg value="--extensions=php" />
<arg value="--error-severity=1" />
<arg path="${basedir}/app" />
</exec>
</target>
<target name="tools.phpmd" description="Check code with PHP Mess Detector">
<exec executable="phpmd">
<arg path="${basedir}/app" />
<arg value="text" />
<arg value="codesize,unusedcode,naming" />
</exec>
</target>
<target name="testing" depends="testing.phpunit" description="Run various testing frameworks" />
<target name="testing.phpunit" description="Run unit tests with PHPUnit">
<exec executable="${basedir}/vendor/bin/phpunit" failonerror="true">
<arg value="-c" />
<arg value="${basedir}/phpunit.xml" />
</exec>
</target>
</project>
@michaelbunch
Copy link
Author

This requires PHP Code Sniffer, PHP Mess Detector, and PHPUnit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment