build - Phing and composer -


we use phing build , test our project. want remove dependencies on pear as possible can run different versions of packages different projects. have created composer.json file install necessary packages

{     "require": {         "php": ">=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/"     } } 

and have phing build.xml

<?xml version="1.0" encoding="utf-8"?>  <project name="solexactconnector" default="build">     <property name="basedir" value="." override="true"/>     <property name="source" value="${basedir}/module"/>      <fileset dir="${source}" id="sourcewithouttests">         <include name="**/*.php"/>          <exclude name="*/test/"/>          <exclude name="*/module.php"/>         <exclude name="*/config/module.config.php"/>         <exclude name="*/test/bootstrap.php"/>     </fileset>      <fileset dir="${source}" id="sourcewithtests">         <include name="**/*.php"/>          <exclude name="*/module.php"/>         <exclude name="*/config/module.config.php"/>         <exclude name="*/test/bootstrap.php"/>     </fileset>      <fileset dir="${source}" id="tests">         <include name="*/test/**/*test.php"/>     </fileset>       <target name="prepare" description="clean , 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/docs"/>          <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/docs"/>     </target>      <target name="phpunit" description="run unit tests" depends="prepare">         <coverage-setup database="${basedir}/build/logs/coverage.db">             <fileset refid="sourcewithouttests"/>         </coverage-setup>         <phpunit haltonfailure="true" haltonerror="true" printsummary="true" bootstrap="test/bootstrap.php"                  codecoverage="true">             <formatter todir="${basedir}/build/logs" type="clover" outfile="clover.xml"/>             <formatter todir="${basedir}/build/logs" type="xml" outfile="junit.xml"/>             <batchtest>                 <fileset refid="tests"/>             </batchtest>         </phpunit>     </target>      <target name="lint" description="perform syntax check of sourcecode files" depends="prepare">         <phplint haltonfailure="true" cachefile="${basedir}/build/logs/lint.cache">             <fileset refid="sourcewithtests"/>         </phplint>     </target>       <target name="pdepend" description="generate jdepend.xml , software metrics charts using php_depend"             depends="prepare">         <phpdepend file="${source}">             <logger type="jdepend-xml" outfile="${basedir}/build/logs/jdepend.xml"/>             <logger type="jdepend-chart" outfile="${basedir}/build/pdepend/dependencies.svg"/>             <logger type="overview-pyramid" outfile="${basedir}/build/pdepend/overview-pyramid.svg"/>         </phpdepend>     </target>      <target name="phpmd" description="generate pmd.xml using phpmd" depends="prepare">         <phpmd file="${source}">             <formatter type="xml" outfile="${basedir}/build/logs/pmd.xml"/>         </phpmd>     </target>      <target name="phpcpd" description="generate pmd-cpd.xml using phpcpd" depends="prepare">         <phpcpd>             <formatter type="pmd" outfile="${basedir}/build/logs/pmd-cpd.xml"/>             <fileset refid="sourcewithtests"/>         </phpcpd>     </target>      <target name="phploc" description="generate phploc.xml" depends="prepare">         <phploc reporttype="xml" reportname="phploc"                 reportdirectory="${basedir}/build/logs">             <fileset refid="sourcewithtests"/>         </phploc>     </target>      <target name="phpcs" description="generate checkstyle.xml using php_codesniffer" depends="prepare">         <phpcodesniffer                 standard="psr2"                 showsniffs="true"                 showwarnings="true">             <fileset refid="sourcewithtests"/>             <formatter type="default" usefile="false"/>             <formatter type="checkstyle" outfile="${basedir}/build/logs/checkstyle-codesniffer.xml"/>         </phpcodesniffer>     </target>      <target name="hphpa" description="hiphop's static analyzer" depends="prepare">         <exec executable="wget" checkreturn="true">             <arg line="https://phar.phpunit.de/hphpa.phar"/>         </exec>         <exec executable="php hphpa.phar" checkreturn="true">             <arg line="--checkstyle ${basedir}/build/logs/checkstyle-hphpa.xml"/>             <arg line="${source}"/>         </exec>         <delete file="hphpa.phar"/>     </target>      <target name="phpdoc2" description="generate api documentation using phpdox" depends="prepare">         <phpdoc2 title="api documentation"                  destdir="${basedir}/build/docs"                  template="responsive-twig">             <fileset refid="sourcewithtests"/>         </phpdoc2>     </target>      <target name="phpcb" description="aggregate tool output php_codebrowser" depends="prepare">         <exec executable="phpcb">             <arg line="--log    ${basedir}/build/logs               --source ${source}               --output ${basedir}/build/code-browser"/>         </exec>     </target>      <target name="composer" description="installing dependencies" depends="prepare">         <delete dir="${basedir}/vendor"/>          <composer command="install">             <arg value="--dev"/>         </composer>     </target>      <target name="doctrine" description="building database/doctrine" depends="prepare">         <copy file="${basedir}/config/autoload/local.php.test" tofile="${basedir}/config/autoload/local.php"               haltonerror="true"/>         <delete dir="${basedir}/data/db/"/>         <mkdir dir="${basedir}/data/db/"/>         <chmod file="${basedir}/data/db/" mode="777"/>          <exec executable="${basedir}/vendor/bin/doctrine-module">             <arg value="orm:schema-tool:create"/>         </exec>          <delete dir="${basedir}/data/doctrineormmodule/proxy"/>         <mkdir dir="${basedir}/data/doctrineormmodule/proxy"/>          <exec executable="${basedir}/vendor/bin/doctrine-module">             <arg value="orm:generate-proxies"/>         </exec>          <exec executable="${basedir}/vendor/bin/doctrine-module">             <arg value="data-fixture:import"/>         </exec>      </target>      <target name="build"             depends="lint,pdepend,phpcs,phpcpd,phpmd,hphpa,phpdoc2,composer,doctrine,phpunit,phpcb"/> </project> 

some targets (like phpunit, phpmd , phploc) run fine others don't? e.g. when run phpcpd error:

execution of target "phpcpd" failed 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 , on include_path.

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 , on include_path. total time: 0.1250 seconds

do need add composer autoload or that?

to use composer autoloader instead of global pear packages can add following line beginning of build.xml:

<php expression="include('vendor/autoload.php')"/> 

this helped me phpunit (i dont have global phpunit pear installation). think load composer packages.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -