title: Phing and composer
body: <p>we use phing to build and test our project. I want to remove dependencies on PEAR as much as possible so I can run different versions of packages for different projects. I have created a composer.json file which install all the necessary packages</p>
  
  <pre><code>{
      "require": {
          "php": "&gt;=5.3.3",
          "zendframework/zendframework": "2.2.*",
          "doctrine/doctrine-orm-module": "*",
          "phpoption/phpoption": "*"
      },
      "require-dev": {
          "phing/phing": "*",
          "phpunit/phpunit": "*",
          "pdepend/pdepend": "*",
          "phpmd/phpmd": "*",
          "phploc/phploc": "*",
          "phpdocumentor/phpdocumentor": "*",
          "squizlabs/php_codesniffer": "*",
          "mayflower/php-codebrowser": "*",
          "sebastian/phpcpd": "*",
          "zendframework/zftool": "dev-master",
          "zendframework/zend-form": "*",
          "hounddog/doctrine-data-fixture-module": "*",
          "pear/console_commandline": "dev-trunk",
          "pear/log": "dev-master",
          "pear/pear_exception": "dev-master"
      },
      "config": {
          "bin-dir": "vendor/bin/"
      }
  }
  </code></pre>
  
  <p>And I have a phing build.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;project name="SolExactConnector" default="build"&gt;
      &lt;property name="basedir" value="." override="true"/&gt;
      &lt;property name="source" value="${basedir}/module"/&gt;
  
      &lt;fileset dir="${source}" id="sourceWithoutTests"&gt;
          &lt;include name="**/*.php"/&gt;
  
          &lt;exclude name="*/test/"/&gt;
  
          &lt;exclude name="*/Module.php"/&gt;
          &lt;exclude name="*/config/module.config.php"/&gt;
          &lt;exclude name="*/test/Bootstrap.php"/&gt;
      &lt;/fileset&gt;
  
      &lt;fileset dir="${source}" id="sourceWithTests"&gt;
          &lt;include name="**/*.php"/&gt;
  
          &lt;exclude name="*/Module.php"/&gt;
          &lt;exclude name="*/config/module.config.php"/&gt;
          &lt;exclude name="*/test/Bootstrap.php"/&gt;
      &lt;/fileset&gt;
  
      &lt;fileset dir="${source}" id="tests"&gt;
          &lt;include name="*/test/**/*Test.php"/&gt;
      &lt;/fileset&gt;
  
  
      &lt;target name="prepare" description="Clean up and create artifact directories"&gt;
          &lt;delete dir="${basedir}/build/api"/&gt;
          &lt;delete dir="${basedir}/build/code-browser"/&gt;
          &lt;delete dir="${basedir}/build/coverage"/&gt;
          &lt;delete dir="${basedir}/build/logs"/&gt;
          &lt;delete dir="${basedir}/build/pdepend"/&gt;
          &lt;delete dir="${basedir}/build/docs"/&gt;
  
          &lt;mkdir dir="${basedir}/build/api"/&gt;
          &lt;mkdir dir="${basedir}/build/code-browser"/&gt;
          &lt;mkdir dir="${basedir}/build/coverage"/&gt;
          &lt;mkdir dir="${basedir}/build/logs"/&gt;
          &lt;mkdir dir="${basedir}/build/pdepend"/&gt;
          &lt;mkdir dir="${basedir}/build/docs"/&gt;
      &lt;/target&gt;
  
      &lt;target name="phpunit" description="Run unit tests" depends="prepare"&gt;
          &lt;coverage-setup database="${basedir}/build/logs/coverage.db"&gt;
              &lt;fileset refid="sourceWithoutTests"/&gt;
          &lt;/coverage-setup&gt;
          &lt;phpunit haltonfailure="true" haltonerror="true" printsummary="true" bootstrap="test/Bootstrap.php"
                   codecoverage="true"&gt;
              &lt;formatter todir="${basedir}/build/logs" type="clover" outfile="clover.xml"/&gt;
              &lt;formatter todir="${basedir}/build/logs" type="xml" outfile="junit.xml"/&gt;
              &lt;batchtest&gt;
                  &lt;fileset refid="tests"/&gt;
              &lt;/batchtest&gt;
          &lt;/phpunit&gt;
      &lt;/target&gt;
  
      &lt;target name="lint" description="Perform syntax check of sourcecode files" depends="prepare"&gt;
          &lt;phplint haltonfailure="true" cachefile="${basedir}/build/logs/lint.cache"&gt;
              &lt;fileset refid="sourceWithTests"/&gt;
          &lt;/phplint&gt;
      &lt;/target&gt;
  
  
      &lt;target name="pdepend" description="Generate jdepend.xml and software metrics charts using PHP_Depend"
              depends="prepare"&gt;
          &lt;phpdepend file="${source}"&gt;
              &lt;logger type="jdepend-xml" outfile="${basedir}/build/logs/jdepend.xml"/&gt;
              &lt;logger type="jdepend-chart" outfile="${basedir}/build/pdepend/dependencies.svg"/&gt;
              &lt;logger type="overview-pyramid" outfile="${basedir}/build/pdepend/overview-pyramid.svg"/&gt;
          &lt;/phpdepend&gt;
      &lt;/target&gt;
  
      &lt;target name="phpmd" description="Generate pmd.xml using PHPMD" depends="prepare"&gt;
          &lt;phpmd file="${source}"&gt;
              &lt;formatter type="xml" outfile="${basedir}/build/logs/pmd.xml"/&gt;
          &lt;/phpmd&gt;
      &lt;/target&gt;
  
      &lt;target name="phpcpd" description="Generate pmd-cpd.xml using PHPCPD" depends="prepare"&gt;
          &lt;phpcpd&gt;
              &lt;formatter type="pmd" outfile="${basedir}/build/logs/pmd-cpd.xml"/&gt;
              &lt;fileset refid="sourceWithTests"/&gt;
          &lt;/phpcpd&gt;
      &lt;/target&gt;
  
      &lt;target name="phploc" description="Generate phploc.xml" depends="prepare"&gt;
          &lt;phploc reportType="xml" reportName="phploc"
                  reportDirectory="${basedir}/build/logs"&gt;
              &lt;fileset refid="sourceWithTests"/&gt;
          &lt;/phploc&gt;
      &lt;/target&gt;
  
      &lt;target name="phpcs" description="Generate checkstyle.xml using PHP_CodeSniffer" depends="prepare"&gt;
          &lt;phpcodesniffer
                  standard="PSR2"
                  showSniffs="true"
                  showWarnings="true"&gt;
              &lt;fileset refid="sourceWithTests"/&gt;
              &lt;formatter type="default" usefile="false"/&gt;
              &lt;formatter type="checkstyle" outfile="${basedir}/build/logs/checkstyle-codesniffer.xml"/&gt;
          &lt;/phpcodesniffer&gt;
      &lt;/target&gt;
  
      &lt;target name="hphpa" description="HipHop's static analyzer" depends="prepare"&gt;
          &lt;exec executable="wget" checkreturn="true"&gt;
              &lt;arg line="https://phar.phpunit.de/hphpa.phar"/&gt;
          &lt;/exec&gt;
          &lt;exec executable="php hphpa.phar" checkreturn="true"&gt;
              &lt;arg line="--checkstyle ${basedir}/build/logs/checkstyle-hphpa.xml"/&gt;
              &lt;arg line="${source}"/&gt;
          &lt;/exec&gt;
          &lt;delete file="hphpa.phar"/&gt;
      &lt;/target&gt;
  
      &lt;target name="phpdoc2" description="Generate API documentation using phpDox" depends="prepare"&gt;
          &lt;phpdoc2 title="API Documentation"
                   destdir="${basedir}/build/docs"
                   template="responsive-twig"&gt;
              &lt;fileset refid="sourceWithTests"/&gt;
          &lt;/phpdoc2&gt;
      &lt;/target&gt;
  
      &lt;target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser" depends="prepare"&gt;
          &lt;exec executable="phpcb"&gt;
              &lt;arg line="--log    ${basedir}/build/logs
                --source ${source}
                --output ${basedir}/build/code-browser"/&gt;
          &lt;/exec&gt;
      &lt;/target&gt;
  
      &lt;target name="composer" description="Installing dependencies" depends="prepare"&gt;
          &lt;delete dir="${basedir}/vendor"/&gt;
  
          &lt;composer command="install"&gt;
              &lt;arg value="--dev"/&gt;
          &lt;/composer&gt;
      &lt;/target&gt;
  
      &lt;target name="doctrine" description="Building Database/Doctrine" depends="prepare"&gt;
          &lt;copy file="${basedir}/config/autoload/local.php.test" tofile="${basedir}/config/autoload/local.php"
                haltonerror="true"/&gt;
          &lt;delete dir="${basedir}/data/db/"/&gt;
          &lt;mkdir dir="${basedir}/data/db/"/&gt;
          &lt;chmod file="${basedir}/data/db/" mode="777"/&gt;
  
          &lt;exec executable="${basedir}/vendor/bin/doctrine-module"&gt;
              &lt;arg value="orm:schema-tool:create"/&gt;
          &lt;/exec&gt;
  
          &lt;delete dir="${basedir}/data/DoctrineORMModule/Proxy"/&gt;
          &lt;mkdir dir="${basedir}/data/DoctrineORMModule/Proxy"/&gt;
  
          &lt;exec executable="${basedir}/vendor/bin/doctrine-module"&gt;
              &lt;arg value="orm:generate-proxies"/&gt;
          &lt;/exec&gt;
  
          &lt;exec executable="${basedir}/vendor/bin/doctrine-module"&gt;
              &lt;arg value="data-fixture:import"/&gt;
          &lt;/exec&gt;
  
      &lt;/target&gt;
  
      &lt;target name="build"
              depends="lint,pdepend,phpcs,phpcpd,phpmd,hphpa,phpdoc2,composer,doctrine,phpunit,phpcb"/&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Some targets (like phpunit, phpmd and phploc) run fine but others don't? E.g. when I run phpcpd I get this error:</p>
  
  <blockquote>
    <p>Execution of target "phpcpd" failed for the following reason:
    /home/munnik/Sites/SolExactConnector/trunk/build.xml:83:16:
    /home/munnik/Sites/SolExactConnector/trunk/build.xml:83:16: PHPCPDTask
    depends on PHPCPD being installed and on include_path.</p>
    
    <p>BUILD FAILED
    /home/munnik/Sites/SolExactConnector/trunk/build.xml:83:16:
    /home/munnik/Sites/SolExactConnector/trunk/build.xml:83:16: PHPCPDTask
    depends on PHPCPD being installed and on include_path. Total time:
    0.1250 seconds</p>
  </blockquote>
  
  <p>Do I need to add the composer autoload or something like that?</p>