Post on 09-May-2015
description
Building com PhingBuilding com Phing(em 7 minutos)(em 7 minutos)
DuodracoDuodraco
PHPSPPHPSPArizonaArizona
Build em PHP?Build em PHP?● Build = automação de processosBuild = automação de processos
– Testes e artefatos de QATestes e artefatos de QA– DeploymentDeployment– AtualizaçãoAtualização– DistribuiçãoDistribuição– VerificaçãoVerificação
PhingPhing● PHPHing ing IIs s NNot ot GGnumakenumake● http://http://phing.infophing.info● Sintaxe do Apache AntSintaxe do Apache Ant
– Buildfile com XMLBuildfile com XML● LógicaLógica● Tarefas CoreTarefas Core● Tarefas OpcionaisTarefas Opcionais
EstruturaEstrutura
<<projectproject default=””> default=””> < <targettarget name=””> name=””> < <tasktask_a param=””/>_a param=””/> <task_b param=””> <task_b param=””> <aux name=”” value=””/> <aux name=”” value=””/> </task_b> </task_b> </target> </target></project</project
Copiando o projeto...Copiando o projeto...
<target name=”le_deploy”><target name=”le_deploy”> < <copycopy todir=”/var/www”> todir=”/var/www”> < <filesetfileset dir="."> dir=".">
<<excludeexclude name=".git" /> name=".git" />
</fileset></fileset>
</copy></copy></target></target>
PHPUnit...PHPUnit...<target name=”phpunit”><target name=”phpunit”> < <phpunitphpunit bootstrap="src/autoload.php" bootstrap="src/autoload.php" codecoverage="true" codecoverage="true" haltonfailure="true" haltonfailure="true" haltonerror="true"> haltonerror="true">
<<formatterformatter type="plain" usefile="false"/> type="plain" usefile="false"/>
<<batchtestbatchtest>>
<<filesetfileset dir="tests"> dir="tests">
<<includeinclude name="**/*Test*.php"/> name="**/*Test*.php"/>
</fileset></fileset>
</batchtest></batchtest>
</phpunit></phpunit></target></target>
Checando dependenciasChecando dependencias
<<targettarget name=”check_dep”> name=”check_dep”> < <composercomposer command=”update”/> command=”update”/></target></target>
● composer.jsoncomposer.json{{ require:{ require:{ “php”:”>5.4.0”, “php”:”>5.4.0”, “ext-imagick”:”*”, “ext-imagick”:”*”, “monolog/monolog”:”0.8.*” “monolog/monolog”:”0.8.*” } }}}
VariáveisVariáveis● build.propertiesbuild.propertiesapp.versionapp.version=13.04=13.04path.log=/var/log/myapps/app.logpath.log=/var/log/myapps/app.logpath.webrootpath.webroot=/var/www=/var/www
● build.xmlbuild.xml<properties file=”build.properties”/><properties file=”build.properties”/><echo msg=”App ver. <echo msg=”App ver. ${app.version}${app.version}”/>”/><copy todir=”<copy todir=”${path.webroot}${path.webroot}”>”> ... ...
Combinando tarefasCombinando tarefas
<target name=”<target name=”phpunitphpunit”>”> … … <target name=”<target name=”pdependpdepend”>”> … … <target name=”<target name=”phpcpdphpcpd”>”> … … <target name=”qa”<target name=”qa” dependsdepends=”=”phpcpdphpcpd,,pdependpdepend,,phpunitphpunit”>”>
OrganizandoOrganizando
<target name=”qa”><target name=”qa”> < <phingphing phingfilephingfile="qa.xml"="qa.xml" inheritRefsinheritRefs="true"="true" targettarget="qa-tests" />="qa-tests" /></target></target><target name=”deploy”><target name=”deploy”> <phing <phing phingfile="deploy.xml" phingfile="deploy.xml" inheritRefs="true" inheritRefs="true" target="install" /> target="install" /></target></target>
Executando...Executando...● # # phingphing● # phing # phing -f-f appbuild.xml appbuild.xml● # phing # phing nossotargetnossotarget
Instalando...Instalando...● pearpear
# pear channel-discover # pear channel-discover pear.phing.infopear.phing.info
# pear install -a # pear install -a phing/phingphing/phing
● composercomposer
phing/phingphing/phing
Obrigado
http://duodra.co