SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
PHPBenelux - Using Phing




          10-5-2011
          ~30 mins

       Marco de Krijger
About me

Marco de Krijger

    http://www.linkedin.com/in/marcodekrijger

    mdekrijger@e-sites.nl
Contents

   What is Phing
   Why using Phing
   Features
   Example Phing build file
   Phing and CI
   Extending Phing
   Questions
What is Phing
   Phing homepage: http://phing.info
    “PHing Is Not GNU make; it's a PHP project
    build system or build tool based on Apache Ant”
   Phing is like a jigsaw
    puzzle. It has a lots
    of easy to use building
    blocks to cover everything
    between a code base and
    a live production
    environment
Why using Phing

   Phing homepage:
    “If you find yourself writing custom scripts to
    handle the packaging, deploying, or testing of
    your applications”
   A shared platform that is maintained →
    less programming && less communication with
    (new) developers                       I'm not needed,
                                               so I can be empty

    “An excellent developer
    makes himself needless”
Features
In a nutshell
Example deployment

   “Phing look and feel” Info target
   e-sites library (ESL)
       Deploy ESL
       Revert version
<?xml version="1.0" encoding="UTF-8"?>
                                       Deployment code
<project name="ESL" default="info">

<target name="deployMinor">
<version releasetype="Minor" file="VERSION" property="version"/>
<svncommit workingcopy="." message="Updated VERSION file to ${version}" username="user" password="password"/>
<svncopy repositoryurl="http://svn.dev/library/esl/Branches/v1" todir="http://svn.dev/library/esl/Tags/release-${version}" username="user"
password="password"/>
<svnupdate todir="." username="user" password="password"/>
<phingcall target="deploy"/>
</target>


<target name="deploy" description="Deploy ESL" depends="tarball">
<fail unless="version" message="Please specify version to export e.g. -Dversion=1.0.0" />
<phingcall target="deployserver">
<property name="host" value="dev"/>
</phingcall>
<!-- clean up mess →
<delete dir="/tmp/eslpackage" quiet="true"/>
</target>

<target name="tarball">
<fail unless="version" message="Please specify version to export e.g. -Dversion=1.0.0" />
<!-- this is to check if SVN tag exists →
<svnlastrevision repositoryurl="http://svn.dev/library/esl/Tags/release-${version}" propertyname="tag" username="user" password="password"/>
<property name="build.dir" value="/tmp/eslpackage" />
<delete dir="${build.dir}" quiet="true"/>
<svnexport username="user" password="password" repositoryurl="http://svn.dev/library/esl/Tags/release-${version}" todir="${build.dir}"/>
<delete file="${build.dir}/build.xml"/>
<tar destfile="/tmp/eslpackage/esl.tar" compression="gzip">
<fileset dir="${build.dir}">
<include name="**/**" />
</fileset>
</tar>
</target>

<target name="deployserver" if="host,version">
<scp username="esites" host="${host}" todir="/tmp" file="/tmp/eslpackage/esl.tar" pubkeyfile="/var/www/.ssh/id_rsa.pub"
privkeyfile="/var/www/.ssh/id_rsa"/>
<!-- untar and symlink →
<ssh username="esites" host="${host}" command="mkdir /var/www/includes/ESL-${version}; cd /var/www/includes/ESL-${version}; tar -zvxf /tmp/esl.tar; ln
-s ./ESL-${version} /var/www/includes/ESLv1_tmp; mv -Tf /var/www/includes/ESLv1_tmp /var/www/includes/ESLv1;rm -f /tmp/esl.tar"
pubkeyfile="/var/www/.ssh/id_rsa.pub" privkeyfile="/var/www/.ssh/id_rsa"/>
</target>
Phing and CI

   Example with Jenkins (Hudson) “building ESL”
       Execute unit tests
       Codesniffer for standards
       PHPMD for mess detection
       Code coverage report for unit test
       PHPDepend stats



                                    +
<?xml version="1.0" encoding="UTF-8"?>
<project name="ESL">
<target name="build" description="Build ESL">
                                                Jenkins build file
<mkdir dir="./reports"/>

<fileset dir="./ESL" id="php.fileset">
<include name="**/*.php"/>
</fileset>

<!-- Set up coverage db →
<coverage-setup database="./reports/coverage.db">
<fileset refid="php.fileset"/>
</coverage-setup>

<!-- Execute unit tests →
<phpunit bootstrap="./bootstrap.php" codecoverage="true">
<formatter type="clover" todir="reports"/>
<formatter type="xml" todir="reports"/>
<batchtest>
<fileset id="unittests" dir="./tests">
<include name="**/*Test.php"/>
</fileset>
</batchtest>
</phpunit>

<!-- Do codesniffing →
<phpcodesniffer standard="Esites" format="checkstyle">
<fileset refid="php.fileset"/>
<formatter type="checkstyle" outfile="./reports/checkstyle.xml"/>
</phpcodesniffer>

<!-- Do PMD checks →
<phpmd rulesets="Esites">
<fileset refid="php.fileset"/>
<formatter type="xml" outfile="./reports/pmd.xml"/>
</phpmd>

<!-- Copy paste detection →
<phpcpd>
<fileset refid="php.fileset"/>
<formatter type="pmd" outfile="./reports/cpd.xml"/>
</phpcpd>

<!-- Get PHPDepend stats →
<phpdepend>
<fileset refid="php.fileset"/>
<logger type="jdepend-xml" outfile="./reports/jdepend.xml"/>
<logger type="jdepend-chart" outfile="./reports/dependencies.svg"/>
<logger type="overview-pyramid" outfile="./reports/overview-pyramid.svg"/>
<analyzer type="coderank-mode" value="method"/>
</phpdepend>

</target>
</project>
Jenkins graphs
            And...
           PHPCPD Copy paste
            detection
           PHPunit test results
Extending Phing

   Example
    Existing SSH task is incomplete. We want
    to capture SSH output for string matching
        Add your task/class to defaults.properties
        Create user directory in tasks
        Create your own task with setters and
         main method
<?xml version="1.0" encoding="UTF-8"?>
                                                 Custom task
<project name="ESL" default="build">

<property name="dir.source" value="/var/www/html/workingcopies/mdkrijger/personal/esltest" />
<property name="dir.destination" value="/tmp/phingdemo" />

<target name="compare" description="Compare 2 fixed directories">
<!-- Create package (tarball) →
<tar destfile="tarball.tar" compression="gzip">
 <fileset dir="${dir.source}">
 <include name="**/**" />
 </fileset>
</tar>
<!-- upload it to production environment →
<scp username="esites" host="dev" todir="/tmp" file="tarball.tar" pubkeyfile="/var/www/.ssh/id_rsa.pub" privkeyfile="/var/www/.ssh/id_rsa"/>
<!-- Extract the uploaded image, display its activity →
<ssh username="esites" host="dev" command="mkdir /tmp/phingdemo; cd /tmp/phingdemo; tar -zxvf /tmp/tarball.tar"
pubkeyfile="/var/www/.ssh/id_rsa.pub" privkeyfile="/var/www/.ssh/id_rsa"/>
<!-- This is the custom task →
<!-- get directory sizes →
<sshterm username="esites" host="devlocal" display="false" property="size1" command="du -bs ${dir.destination} | egrep -o '([0-9]*)'"
pubkeyfile="/var/www/.ssh/id_rsa.pub" privkeyfile="/var/www/.ssh/id_rsa"/>
<exec command="du -bs ${dir.source} | egrep -o '([0-9]*)'" outputproperty="size2"/>
<!-- compare them →
<if>
<not>
<equals arg1="${size1}" arg2="${size2}"/>
</not>
<then>
<fail message="Directories are not in sync! Size source: ${size2}, Size destination: ${size1}"/>
</then>
<else>
<echo message="Directories are in sync"/>
</else>
</if>
</target>

<target name="clean">
<delete dir="/tmp/phingdemo"/>
<delete file="/tmp/tarball.tar"/>
</target>

<target name="break">
<copy file="/tmp/tarball.tar" tofile="${dir.destination}/tarball.tar" overwrite="true"/>
</target>
</project>
Further reading

   Phing website
    http://phing.info
   Jenkins CI
    http://jenkins-ci.org
   Setting up Phing under Jenkins
    http://bit.ly/9EgmN
   This presentation
    http://www.slideshare.net/mdekrijger/phing-7900127
Questions?

   If any

Weitere ähnliche Inhalte

Was ist angesagt?

Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP ApplicationsPavan Kumar N
 
Automated Deployment With Phing
Automated Deployment With PhingAutomated Deployment With Phing
Automated Deployment With PhingDaniel Cousineau
 
Best Practices in PHP Application Deployment
Best Practices in PHP Application DeploymentBest Practices in PHP Application Deployment
Best Practices in PHP Application DeploymentShahar Evron
 
Propel Your PHP Applications
Propel Your PHP ApplicationsPropel Your PHP Applications
Propel Your PHP Applicationshozn
 
Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsAdam Culp
 
Zend Framework 1.8 workshop
Zend Framework 1.8 workshopZend Framework 1.8 workshop
Zend Framework 1.8 workshopNick Belhomme
 
Vagrant move over, here is Docker
Vagrant move over, here is DockerVagrant move over, here is Docker
Vagrant move over, here is DockerNick Belhomme
 
PHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBeneluxPHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBeneluxNick Belhomme
 
Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Clark Everetts
 
Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginnersAdam Englander
 
11 tools for your PHP devops stack
11 tools for your PHP devops stack11 tools for your PHP devops stack
11 tools for your PHP devops stackKris Buytaert
 
Laravel 4 package development
Laravel 4 package developmentLaravel 4 package development
Laravel 4 package developmentTihomir Opačić
 
New EEA Plone Add-ons
New EEA Plone Add-onsNew EEA Plone Add-ons
New EEA Plone Add-onsAlin Voinea
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using DjangoNathan Eror
 
Virtual Bolt Workshop - 6 May
Virtual Bolt Workshop - 6 MayVirtual Bolt Workshop - 6 May
Virtual Bolt Workshop - 6 MayPuppet
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial之宇 趙
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php PresentationAlan Pinstein
 
Puppet Virtual Bolt Workshop - 23 April 2020 (Singapore)
Puppet Virtual Bolt Workshop - 23 April 2020 (Singapore)Puppet Virtual Bolt Workshop - 23 April 2020 (Singapore)
Puppet Virtual Bolt Workshop - 23 April 2020 (Singapore)Puppet
 
Ansible project-deploy (NomadPHP lightning talk)
Ansible project-deploy (NomadPHP lightning talk)Ansible project-deploy (NomadPHP lightning talk)
Ansible project-deploy (NomadPHP lightning talk)Ramon de la Fuente
 

Was ist angesagt? (20)

Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
 
Automated Deployment With Phing
Automated Deployment With PhingAutomated Deployment With Phing
Automated Deployment With Phing
 
Best Practices in PHP Application Deployment
Best Practices in PHP Application DeploymentBest Practices in PHP Application Deployment
Best Practices in PHP Application Deployment
 
Propel Your PHP Applications
Propel Your PHP ApplicationsPropel Your PHP Applications
Propel Your PHP Applications
 
Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with Jenkins
 
Zend Framework 1.8 workshop
Zend Framework 1.8 workshopZend Framework 1.8 workshop
Zend Framework 1.8 workshop
 
Vagrant move over, here is Docker
Vagrant move over, here is DockerVagrant move over, here is Docker
Vagrant move over, here is Docker
 
PHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBeneluxPHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBenelux
 
Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016
 
Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginners
 
11 tools for your PHP devops stack
11 tools for your PHP devops stack11 tools for your PHP devops stack
11 tools for your PHP devops stack
 
Laravel 4 package development
Laravel 4 package developmentLaravel 4 package development
Laravel 4 package development
 
New EEA Plone Add-ons
New EEA Plone Add-onsNew EEA Plone Add-ons
New EEA Plone Add-ons
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using Django
 
Virtual Bolt Workshop - 6 May
Virtual Bolt Workshop - 6 MayVirtual Bolt Workshop - 6 May
Virtual Bolt Workshop - 6 May
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
 
Continuous Quality Assurance
Continuous Quality AssuranceContinuous Quality Assurance
Continuous Quality Assurance
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Puppet Virtual Bolt Workshop - 23 April 2020 (Singapore)
Puppet Virtual Bolt Workshop - 23 April 2020 (Singapore)Puppet Virtual Bolt Workshop - 23 April 2020 (Singapore)
Puppet Virtual Bolt Workshop - 23 April 2020 (Singapore)
 
Ansible project-deploy (NomadPHP lightning talk)
Ansible project-deploy (NomadPHP lightning talk)Ansible project-deploy (NomadPHP lightning talk)
Ansible project-deploy (NomadPHP lightning talk)
 

Ähnlich wie Phing

IzPack at LyonJUG'11
IzPack at LyonJUG'11IzPack at LyonJUG'11
IzPack at LyonJUG'11julien.ponge
 
Building com Phing - 7Masters PHP
Building com Phing - 7Masters PHPBuilding com Phing - 7Masters PHP
Building com Phing - 7Masters PHPiMasters
 
BP-6 Repository Customization Best Practices
BP-6 Repository Customization Best PracticesBP-6 Repository Customization Best Practices
BP-6 Repository Customization Best PracticesAlfresco Software
 
Apache ant
Apache antApache ant
Apache antkoniik
 
Improving QA on PHP projects - confoo 2011
Improving QA on PHP projects - confoo 2011Improving QA on PHP projects - confoo 2011
Improving QA on PHP projects - confoo 2011Michelangelo van Dam
 
"I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more."I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more.Fabio Milano
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012Carlos Sanchez
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Bastian Feder
 
Deployment Tactics
Deployment TacticsDeployment Tactics
Deployment TacticsIan Barber
 
Introduction to InSpec and 1.0 release update
Introduction to InSpec and 1.0 release updateIntroduction to InSpec and 1.0 release update
Introduction to InSpec and 1.0 release updateAlex Pop
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)LumoSpark
 
Phing i Fabric - Budowanie i deployment aplikacji webowych
Phing i Fabric - Budowanie i deployment aplikacji webowychPhing i Fabric - Budowanie i deployment aplikacji webowych
Phing i Fabric - Budowanie i deployment aplikacji webowychleafnode
 
Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013grim_radical
 
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise securityMuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise securityakashdprajapati
 
Introduction to puppet - Hands on Session at HPI Potsdam
Introduction to puppet - Hands on Session at HPI PotsdamIntroduction to puppet - Hands on Session at HPI Potsdam
Introduction to puppet - Hands on Session at HPI PotsdamChristoph Oelmüller
 

Ähnlich wie Phing (20)

Write php deploy everywhere tek11
Write php deploy everywhere   tek11Write php deploy everywhere   tek11
Write php deploy everywhere tek11
 
Write php deploy everywhere
Write php deploy everywhereWrite php deploy everywhere
Write php deploy everywhere
 
IzPack at LyonJUG'11
IzPack at LyonJUG'11IzPack at LyonJUG'11
IzPack at LyonJUG'11
 
Building com Phing - 7Masters PHP
Building com Phing - 7Masters PHPBuilding com Phing - 7Masters PHP
Building com Phing - 7Masters PHP
 
BP-6 Repository Customization Best Practices
BP-6 Repository Customization Best PracticesBP-6 Repository Customization Best Practices
BP-6 Repository Customization Best Practices
 
Apache ant
Apache antApache ant
Apache ant
 
Improving QA on PHP projects - confoo 2011
Improving QA on PHP projects - confoo 2011Improving QA on PHP projects - confoo 2011
Improving QA on PHP projects - confoo 2011
 
"I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more."I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more.
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
Deployment Tactics
Deployment TacticsDeployment Tactics
Deployment Tactics
 
Introduction to InSpec and 1.0 release update
Introduction to InSpec and 1.0 release updateIntroduction to InSpec and 1.0 release update
Introduction to InSpec and 1.0 release update
 
Php Power Tools
Php Power ToolsPhp Power Tools
Php Power Tools
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)
 
Phing i Fabric - Budowanie i deployment aplikacji webowych
Phing i Fabric - Budowanie i deployment aplikacji webowychPhing i Fabric - Budowanie i deployment aplikacji webowych
Phing i Fabric - Budowanie i deployment aplikacji webowych
 
Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013
 
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise securityMuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
 
Algotitmo Moinho
Algotitmo MoinhoAlgotitmo Moinho
Algotitmo Moinho
 
Introduction to puppet - Hands on Session at HPI Potsdam
Introduction to puppet - Hands on Session at HPI PotsdamIntroduction to puppet - Hands on Session at HPI Potsdam
Introduction to puppet - Hands on Session at HPI Potsdam
 

Kürzlich hochgeladen

"There are probably more Nobel Laureates who are people of faith than is gen...
 "There are probably more Nobel Laureates who are people of faith than is gen... "There are probably more Nobel Laureates who are people of faith than is gen...
"There are probably more Nobel Laureates who are people of faith than is gen...Steven Camilleri
 
Meaningful Pursuits: Pursuing Obedience_Ecclesiastes.pptx
Meaningful Pursuits: Pursuing Obedience_Ecclesiastes.pptxMeaningful Pursuits: Pursuing Obedience_Ecclesiastes.pptx
Meaningful Pursuits: Pursuing Obedience_Ecclesiastes.pptxStephen Palm
 
A357 Hate can stir up strife, but love can cover up all mistakes. hate, love...
A357 Hate can stir up strife, but love can cover up all mistakes.  hate, love...A357 Hate can stir up strife, but love can cover up all mistakes.  hate, love...
A357 Hate can stir up strife, but love can cover up all mistakes. hate, love...franktsao4
 
Deerfoot Church of Christ Bulletin 2 25 24
Deerfoot Church of Christ Bulletin 2 25 24Deerfoot Church of Christ Bulletin 2 25 24
Deerfoot Church of Christ Bulletin 2 25 24deerfootcoc
 
Gangaur Celebrations 2024 - Rajasthani Sewa Samaj Karimnagar, Telangana State...
Gangaur Celebrations 2024 - Rajasthani Sewa Samaj Karimnagar, Telangana State...Gangaur Celebrations 2024 - Rajasthani Sewa Samaj Karimnagar, Telangana State...
Gangaur Celebrations 2024 - Rajasthani Sewa Samaj Karimnagar, Telangana State...INDIAN YOUTH SECURED ORGANISATION
 
Ayodhya Temple saw its first Big Navratri Festival!
Ayodhya Temple saw its first Big Navratri Festival!Ayodhya Temple saw its first Big Navratri Festival!
Ayodhya Temple saw its first Big Navratri Festival!All in One Trendz
 
Prach Autism AI - Artificial Intelligence
Prach Autism AI - Artificial IntelligencePrach Autism AI - Artificial Intelligence
Prach Autism AI - Artificial Intelligenceprachaibot
 
Secrets of Divine Love - A Spiritual Journey into the Heart of Islam - A. Helwa
Secrets of Divine Love - A Spiritual Journey into the Heart of Islam - A. HelwaSecrets of Divine Love - A Spiritual Journey into the Heart of Islam - A. Helwa
Secrets of Divine Love - A Spiritual Journey into the Heart of Islam - A. HelwaNodd Nittong
 
Praise and worship slides will lyrics and pictures
Praise and worship slides will lyrics and picturesPraise and worship slides will lyrics and pictures
Praise and worship slides will lyrics and picturesmrbeandone
 
Deerfoot Church of Christ Bulletin 3 31 24
Deerfoot Church of Christ Bulletin 3 31 24Deerfoot Church of Christ Bulletin 3 31 24
Deerfoot Church of Christ Bulletin 3 31 24deerfootcoc
 
A Tsunami Tragedy ~ Wise Reflections for Troubled Times (Eng. & Chi.).pptx
A Tsunami Tragedy ~ Wise Reflections for Troubled Times (Eng. & Chi.).pptxA Tsunami Tragedy ~ Wise Reflections for Troubled Times (Eng. & Chi.).pptx
A Tsunami Tragedy ~ Wise Reflections for Troubled Times (Eng. & Chi.).pptxOH TEIK BIN
 
The King 'Great Goodness' Part 1 Mahasilava Jataka (Eng. & Chi.).pptx
The King 'Great Goodness' Part 1 Mahasilava Jataka (Eng. & Chi.).pptxThe King 'Great Goodness' Part 1 Mahasilava Jataka (Eng. & Chi.).pptx
The King 'Great Goodness' Part 1 Mahasilava Jataka (Eng. & Chi.).pptxOH TEIK BIN
 
Monthly Khazina-e-Ruhaniyaat April’2024 (Vol.14, Issue 12)
Monthly Khazina-e-Ruhaniyaat April’2024 (Vol.14, Issue 12)Monthly Khazina-e-Ruhaniyaat April’2024 (Vol.14, Issue 12)
Monthly Khazina-e-Ruhaniyaat April’2024 (Vol.14, Issue 12)Darul Amal Chishtia
 
Deerfoot Church of Christ Bulletin 4 14 24
Deerfoot Church of Christ Bulletin 4 14 24Deerfoot Church of Christ Bulletin 4 14 24
Deerfoot Church of Christ Bulletin 4 14 24deerfootcoc
 
Codex Singularity: Search for the Prisca Sapientia
Codex Singularity: Search for the Prisca SapientiaCodex Singularity: Search for the Prisca Sapientia
Codex Singularity: Search for the Prisca Sapientiajfrenchau
 
The-Clear-Quran,-A-Thematic-English-Translation-by-Dr-Mustafa-Khattab.pdf
The-Clear-Quran,-A-Thematic-English-Translation-by-Dr-Mustafa-Khattab.pdfThe-Clear-Quran,-A-Thematic-English-Translation-by-Dr-Mustafa-Khattab.pdf
The-Clear-Quran,-A-Thematic-English-Translation-by-Dr-Mustafa-Khattab.pdfSana Khan
 
empathy map for students very useful.pptx
empathy map for students very useful.pptxempathy map for students very useful.pptx
empathy map for students very useful.pptxGeorgePhilips7
 

Kürzlich hochgeladen (20)

"There are probably more Nobel Laureates who are people of faith than is gen...
 "There are probably more Nobel Laureates who are people of faith than is gen... "There are probably more Nobel Laureates who are people of faith than is gen...
"There are probably more Nobel Laureates who are people of faith than is gen...
 
Meaningful Pursuits: Pursuing Obedience_Ecclesiastes.pptx
Meaningful Pursuits: Pursuing Obedience_Ecclesiastes.pptxMeaningful Pursuits: Pursuing Obedience_Ecclesiastes.pptx
Meaningful Pursuits: Pursuing Obedience_Ecclesiastes.pptx
 
A357 Hate can stir up strife, but love can cover up all mistakes. hate, love...
A357 Hate can stir up strife, but love can cover up all mistakes.  hate, love...A357 Hate can stir up strife, but love can cover up all mistakes.  hate, love...
A357 Hate can stir up strife, but love can cover up all mistakes. hate, love...
 
Deerfoot Church of Christ Bulletin 2 25 24
Deerfoot Church of Christ Bulletin 2 25 24Deerfoot Church of Christ Bulletin 2 25 24
Deerfoot Church of Christ Bulletin 2 25 24
 
Gangaur Celebrations 2024 - Rajasthani Sewa Samaj Karimnagar, Telangana State...
Gangaur Celebrations 2024 - Rajasthani Sewa Samaj Karimnagar, Telangana State...Gangaur Celebrations 2024 - Rajasthani Sewa Samaj Karimnagar, Telangana State...
Gangaur Celebrations 2024 - Rajasthani Sewa Samaj Karimnagar, Telangana State...
 
Ayodhya Temple saw its first Big Navratri Festival!
Ayodhya Temple saw its first Big Navratri Festival!Ayodhya Temple saw its first Big Navratri Festival!
Ayodhya Temple saw its first Big Navratri Festival!
 
Prach Autism AI - Artificial Intelligence
Prach Autism AI - Artificial IntelligencePrach Autism AI - Artificial Intelligence
Prach Autism AI - Artificial Intelligence
 
English - The Dangers of Wine Alcohol.pptx
English - The Dangers of Wine Alcohol.pptxEnglish - The Dangers of Wine Alcohol.pptx
English - The Dangers of Wine Alcohol.pptx
 
Secrets of Divine Love - A Spiritual Journey into the Heart of Islam - A. Helwa
Secrets of Divine Love - A Spiritual Journey into the Heart of Islam - A. HelwaSecrets of Divine Love - A Spiritual Journey into the Heart of Islam - A. Helwa
Secrets of Divine Love - A Spiritual Journey into the Heart of Islam - A. Helwa
 
Top 8 Krishna Bhajan Lyrics in English.pdf
Top 8 Krishna Bhajan Lyrics in English.pdfTop 8 Krishna Bhajan Lyrics in English.pdf
Top 8 Krishna Bhajan Lyrics in English.pdf
 
Praise and worship slides will lyrics and pictures
Praise and worship slides will lyrics and picturesPraise and worship slides will lyrics and pictures
Praise and worship slides will lyrics and pictures
 
The spiritual moderator of vincentian groups
The spiritual moderator of vincentian groupsThe spiritual moderator of vincentian groups
The spiritual moderator of vincentian groups
 
Deerfoot Church of Christ Bulletin 3 31 24
Deerfoot Church of Christ Bulletin 3 31 24Deerfoot Church of Christ Bulletin 3 31 24
Deerfoot Church of Christ Bulletin 3 31 24
 
A Tsunami Tragedy ~ Wise Reflections for Troubled Times (Eng. & Chi.).pptx
A Tsunami Tragedy ~ Wise Reflections for Troubled Times (Eng. & Chi.).pptxA Tsunami Tragedy ~ Wise Reflections for Troubled Times (Eng. & Chi.).pptx
A Tsunami Tragedy ~ Wise Reflections for Troubled Times (Eng. & Chi.).pptx
 
The King 'Great Goodness' Part 1 Mahasilava Jataka (Eng. & Chi.).pptx
The King 'Great Goodness' Part 1 Mahasilava Jataka (Eng. & Chi.).pptxThe King 'Great Goodness' Part 1 Mahasilava Jataka (Eng. & Chi.).pptx
The King 'Great Goodness' Part 1 Mahasilava Jataka (Eng. & Chi.).pptx
 
Monthly Khazina-e-Ruhaniyaat April’2024 (Vol.14, Issue 12)
Monthly Khazina-e-Ruhaniyaat April’2024 (Vol.14, Issue 12)Monthly Khazina-e-Ruhaniyaat April’2024 (Vol.14, Issue 12)
Monthly Khazina-e-Ruhaniyaat April’2024 (Vol.14, Issue 12)
 
Deerfoot Church of Christ Bulletin 4 14 24
Deerfoot Church of Christ Bulletin 4 14 24Deerfoot Church of Christ Bulletin 4 14 24
Deerfoot Church of Christ Bulletin 4 14 24
 
Codex Singularity: Search for the Prisca Sapientia
Codex Singularity: Search for the Prisca SapientiaCodex Singularity: Search for the Prisca Sapientia
Codex Singularity: Search for the Prisca Sapientia
 
The-Clear-Quran,-A-Thematic-English-Translation-by-Dr-Mustafa-Khattab.pdf
The-Clear-Quran,-A-Thematic-English-Translation-by-Dr-Mustafa-Khattab.pdfThe-Clear-Quran,-A-Thematic-English-Translation-by-Dr-Mustafa-Khattab.pdf
The-Clear-Quran,-A-Thematic-English-Translation-by-Dr-Mustafa-Khattab.pdf
 
empathy map for students very useful.pptx
empathy map for students very useful.pptxempathy map for students very useful.pptx
empathy map for students very useful.pptx
 

Phing

  • 1. PHPBenelux - Using Phing 10-5-2011 ~30 mins Marco de Krijger
  • 2. About me Marco de Krijger http://www.linkedin.com/in/marcodekrijger mdekrijger@e-sites.nl
  • 3. Contents  What is Phing  Why using Phing  Features  Example Phing build file  Phing and CI  Extending Phing  Questions
  • 4. What is Phing  Phing homepage: http://phing.info “PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant”  Phing is like a jigsaw puzzle. It has a lots of easy to use building blocks to cover everything between a code base and a live production environment
  • 5. Why using Phing  Phing homepage: “If you find yourself writing custom scripts to handle the packaging, deploying, or testing of your applications”  A shared platform that is maintained → less programming && less communication with (new) developers I'm not needed, so I can be empty “An excellent developer makes himself needless”
  • 7. Example deployment  “Phing look and feel” Info target  e-sites library (ESL)  Deploy ESL  Revert version
  • 8. <?xml version="1.0" encoding="UTF-8"?> Deployment code <project name="ESL" default="info"> <target name="deployMinor"> <version releasetype="Minor" file="VERSION" property="version"/> <svncommit workingcopy="." message="Updated VERSION file to ${version}" username="user" password="password"/> <svncopy repositoryurl="http://svn.dev/library/esl/Branches/v1" todir="http://svn.dev/library/esl/Tags/release-${version}" username="user" password="password"/> <svnupdate todir="." username="user" password="password"/> <phingcall target="deploy"/> </target> <target name="deploy" description="Deploy ESL" depends="tarball"> <fail unless="version" message="Please specify version to export e.g. -Dversion=1.0.0" /> <phingcall target="deployserver"> <property name="host" value="dev"/> </phingcall> <!-- clean up mess → <delete dir="/tmp/eslpackage" quiet="true"/> </target> <target name="tarball"> <fail unless="version" message="Please specify version to export e.g. -Dversion=1.0.0" /> <!-- this is to check if SVN tag exists → <svnlastrevision repositoryurl="http://svn.dev/library/esl/Tags/release-${version}" propertyname="tag" username="user" password="password"/> <property name="build.dir" value="/tmp/eslpackage" /> <delete dir="${build.dir}" quiet="true"/> <svnexport username="user" password="password" repositoryurl="http://svn.dev/library/esl/Tags/release-${version}" todir="${build.dir}"/> <delete file="${build.dir}/build.xml"/> <tar destfile="/tmp/eslpackage/esl.tar" compression="gzip"> <fileset dir="${build.dir}"> <include name="**/**" /> </fileset> </tar> </target> <target name="deployserver" if="host,version"> <scp username="esites" host="${host}" todir="/tmp" file="/tmp/eslpackage/esl.tar" pubkeyfile="/var/www/.ssh/id_rsa.pub" privkeyfile="/var/www/.ssh/id_rsa"/> <!-- untar and symlink → <ssh username="esites" host="${host}" command="mkdir /var/www/includes/ESL-${version}; cd /var/www/includes/ESL-${version}; tar -zvxf /tmp/esl.tar; ln -s ./ESL-${version} /var/www/includes/ESLv1_tmp; mv -Tf /var/www/includes/ESLv1_tmp /var/www/includes/ESLv1;rm -f /tmp/esl.tar" pubkeyfile="/var/www/.ssh/id_rsa.pub" privkeyfile="/var/www/.ssh/id_rsa"/> </target>
  • 9. Phing and CI  Example with Jenkins (Hudson) “building ESL”  Execute unit tests  Codesniffer for standards  PHPMD for mess detection  Code coverage report for unit test  PHPDepend stats +
  • 10. <?xml version="1.0" encoding="UTF-8"?> <project name="ESL"> <target name="build" description="Build ESL"> Jenkins build file <mkdir dir="./reports"/> <fileset dir="./ESL" id="php.fileset"> <include name="**/*.php"/> </fileset> <!-- Set up coverage db → <coverage-setup database="./reports/coverage.db"> <fileset refid="php.fileset"/> </coverage-setup> <!-- Execute unit tests → <phpunit bootstrap="./bootstrap.php" codecoverage="true"> <formatter type="clover" todir="reports"/> <formatter type="xml" todir="reports"/> <batchtest> <fileset id="unittests" dir="./tests"> <include name="**/*Test.php"/> </fileset> </batchtest> </phpunit> <!-- Do codesniffing → <phpcodesniffer standard="Esites" format="checkstyle"> <fileset refid="php.fileset"/> <formatter type="checkstyle" outfile="./reports/checkstyle.xml"/> </phpcodesniffer> <!-- Do PMD checks → <phpmd rulesets="Esites"> <fileset refid="php.fileset"/> <formatter type="xml" outfile="./reports/pmd.xml"/> </phpmd> <!-- Copy paste detection → <phpcpd> <fileset refid="php.fileset"/> <formatter type="pmd" outfile="./reports/cpd.xml"/> </phpcpd> <!-- Get PHPDepend stats → <phpdepend> <fileset refid="php.fileset"/> <logger type="jdepend-xml" outfile="./reports/jdepend.xml"/> <logger type="jdepend-chart" outfile="./reports/dependencies.svg"/> <logger type="overview-pyramid" outfile="./reports/overview-pyramid.svg"/> <analyzer type="coderank-mode" value="method"/> </phpdepend> </target> </project>
  • 11. Jenkins graphs And...  PHPCPD Copy paste detection  PHPunit test results
  • 12. Extending Phing  Example Existing SSH task is incomplete. We want to capture SSH output for string matching  Add your task/class to defaults.properties  Create user directory in tasks  Create your own task with setters and main method
  • 13. <?xml version="1.0" encoding="UTF-8"?> Custom task <project name="ESL" default="build"> <property name="dir.source" value="/var/www/html/workingcopies/mdkrijger/personal/esltest" /> <property name="dir.destination" value="/tmp/phingdemo" /> <target name="compare" description="Compare 2 fixed directories"> <!-- Create package (tarball) → <tar destfile="tarball.tar" compression="gzip"> <fileset dir="${dir.source}"> <include name="**/**" /> </fileset> </tar> <!-- upload it to production environment → <scp username="esites" host="dev" todir="/tmp" file="tarball.tar" pubkeyfile="/var/www/.ssh/id_rsa.pub" privkeyfile="/var/www/.ssh/id_rsa"/> <!-- Extract the uploaded image, display its activity → <ssh username="esites" host="dev" command="mkdir /tmp/phingdemo; cd /tmp/phingdemo; tar -zxvf /tmp/tarball.tar" pubkeyfile="/var/www/.ssh/id_rsa.pub" privkeyfile="/var/www/.ssh/id_rsa"/> <!-- This is the custom task → <!-- get directory sizes → <sshterm username="esites" host="devlocal" display="false" property="size1" command="du -bs ${dir.destination} | egrep -o '([0-9]*)'" pubkeyfile="/var/www/.ssh/id_rsa.pub" privkeyfile="/var/www/.ssh/id_rsa"/> <exec command="du -bs ${dir.source} | egrep -o '([0-9]*)'" outputproperty="size2"/> <!-- compare them → <if> <not> <equals arg1="${size1}" arg2="${size2}"/> </not> <then> <fail message="Directories are not in sync! Size source: ${size2}, Size destination: ${size1}"/> </then> <else> <echo message="Directories are in sync"/> </else> </if> </target> <target name="clean"> <delete dir="/tmp/phingdemo"/> <delete file="/tmp/tarball.tar"/> </target> <target name="break"> <copy file="/tmp/tarball.tar" tofile="${dir.destination}/tarball.tar" overwrite="true"/> </target> </project>
  • 14. Further reading  Phing website http://phing.info  Jenkins CI http://jenkins-ci.org  Setting up Phing under Jenkins http://bit.ly/9EgmN  This presentation http://www.slideshare.net/mdekrijger/phing-7900127
  • 15. Questions?  If any