SlideShare a Scribd company logo
Deploying PHP applications with Phing




                                       Michiel Rook

                   PHPNW11 - October 8th, 2011




               Deploying PHP applications with Phing – 1 / 37
About me


Freelance PHP/Java consultant

Phing project lead

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

@michieltcs




                                    Deploying PHP applications with Phing – 2 / 37
About Phing


PHing Is Not GNU make; it’s a PHP project build system or build tool based on
Apache Ant.

Originally developed by Binarycloud

Ported to PHP5 by Hans Lellelid

I joined in 2005




                                                  Deploying PHP applications with Phing – 3 / 37
Features


Scripting using XML build les

Mostly cross-platform

Interface to various popular (PHP) tools




                                           Deploying PHP applications with Phing – 4 / 37
Features




Deploying PHP applications with Phing – 5 / 37
Installation


PEAR installation

$ pear channel-discover pear.phing.info
$ pear install [--alldeps] phing/phing

Optionally, install the documentation package

$ pear install phing/phingdocs




                                                Deploying PHP applications with Phing – 6 / 37
Why Use A Build Tool?




                        Deploying PHP applications with Phing – 7 / 37
Why Use A Build Tool


Repetitive tasks

     Version control
     (Unit) Testing
     Conguring
     Packaging
     Uploading
     DB changes
     ...




                       Deploying PHP applications with Phing – 8 / 37
Why Use A Build Tool


For developers and administrators

Automate!

     Easier handover to new team members
     Improves quality
     Reduces errors
     Saves time




                                           Deploying PHP applications with Phing – 9 / 37
Why Use Phing


Rich set of tasks

Integration with PHP specic tools

Allows you to stay in the PHP infrastructure

Easy to extend

Embed PHP code directly in the build le




                                               Deploying PHP applications with Phing – 10 / 37
Why Use Phing


Rich set of tasks

Integration with PHP specic tools

Allows you to stay in the PHP infrastructure

Easy to extend

Embed PHP code directly in the build le

... in the end, the choice is yours




                                               Deploying PHP applications with Phing – 10 / 37
The Basics




             Deploying PHP applications with Phing – 11 / 37
Build Files


Phing uses XML build les

Contain standard elements

     Task: code that performs a specic function (svn checkout, mkdir, etc.)
     Target: groups of tasks, can optionally depend on other targets
     Project: root node, contains multiple targets




                                                     Deploying PHP applications with Phing – 12 / 37
Example Build File


<project name="Example" default="world">
    <target name="hello">
        <echo>Hello</echo>
    </target>

    <target name="world" depends="hello">
        <echo>World!</echo>
    </target>
</project>




                                           Deploying PHP applications with Phing – 13 / 37
Properties


 Simple key-value les (.ini)

## build.properties
version=1.0

 Can be expanded by using ${key} in the build le

$ phing -propertyfile build.properties ...

<project name="Example" default="default">
    <property file="build.properties" />

    <target name="default">
        <echo>${version}</echo>
    </target>
</project>




                                                    Deploying PHP applications with Phing – 14 / 37
File Sets


 Constructs a group of les to process

 Supported by most tasks

<fileset dir="./application" includes="**"/>

<fileset dir="./application">
    <include name="**/*.php" />
    <exclude name="**/*Test.php" />
</fileset>

 Supports references

<fileset dir="./application" includes="**" id="files"/>

<fileset refid="files"/>




                                         Deploying PHP applications with Phing – 15 / 37
File Sets


 Selectors allow ne-grained matching on certain attributes

 contains, date, le name & size, ...

<fileset dir="${dist}">
    <and>
        <filename name="**"/>
        <date datetime="01/01/2011" when="before"/>
    </and>
</fileset>




                                                   Deploying PHP applications with Phing – 16 / 37
Mappers and Filters


Transform les during copy/move/...

Mappers

      Change lename

Filters

      Strip comments, white space
      Replace values
      Perform XSLT transformation
      Translation (i18n)




                                      Deploying PHP applications with Phing – 17 / 37
Mappers and Filters


<copy todir="${build}">
    <fileset refid="files"/>
    <mapper type="glob" from="*.txt" to="*.new.txt"/>
    <filterchain>
        <replaceregexp>
            <regexp pattern="rn" replace="n"/>
            <expandproperties/>
        </replaceregexp>
    </filterchain>
</copy>




                                        Deploying PHP applications with Phing – 18 / 37
Practical Examples




                     Deploying PHP applications with Phing – 19 / 37
Testing


Built-in support for PHPUnit / SimpleTest

Code coverage through XDebug

Various output formats




                                            Deploying PHP applications with Phing – 20 / 37
PHPUnit


<target name="test">
    <coverage-setup database="reports/coverage.db">
        <fileset dir="src">
            <include name="**/*.php"/>
            <exclude name="**/*Test.php"/>
        </fileset>
    </coverage-setup>
    <phpunit codecoverage="true">
        <formatter type="xml" todir="reports"/>
        <batchtest>
            <fileset dir="src">
                <include name="**/*Test.php"/>
            </fileset>
        </batchtest>
    </phpunit>
    <phpunitreport infile="reports/testsuites.xml"
        format="frames" todir="reports/tests"/>
    <coverage-report outfile="reports/coverage.xml">
        <report todir="reports/coverage" title="Demo"/>
    </coverage-report>
</target>
                                        Deploying PHP applications with Phing – 21 / 37
DocBlox


<target name="docs">
    <docblox title="Phing API Documentation"
        output="docs" quiet="true">
        <fileset dir="../../classes">
            <include name="**/*.php"/>
        </fileset>
    </docblox>
</target>




                                        Deploying PHP applications with Phing – 22 / 37
Database Migration


DbDeploy

Set of delta les (SQL)

Tracks current version in changelog table

Generates do & undo scripts




                                            Deploying PHP applications with Phing – 23 / 37
Database Migration


 Numbered delta le (1-create-post.sql)

 Apply & undo statements

--//

CREATE TABLE ‘post‘ (
    ‘title‘ VARCHAR(255),
    ‘time_created‘ DATETIME,
    ‘content‘ MEDIUMTEXT
);

--//@UNDO

DROP TABLE ‘post‘;

--//




                                          Deploying PHP applications with Phing – 24 / 37
Database Migration


<target name="migrate">
    <dbdeploy
        url="sqlite:test.db"
        dir="deltas"
        outputfile="deploy.sql"
        undooutputfile="undo.sql"/>

    <pdosqlexec
        src="deploy.sql"
        url="sqlite:test.db"/>
</target>




                                      Deploying PHP applications with Phing – 25 / 37
Packaging


 Create complete PEAR packages

<pearpkg name="demo" dir=".">
    <fileset refid="files"/>

   <option   name="outputdirectory" value="./build"/>
   <option   name="description">Test package</option>
   <option   name="version" value="0.1.0"/>
   <option   name="state" value="beta"/>

    <mapping name="maintainers">
        <element>
            <element key="handle" value="test"/>
            <element key="name" value="Test"/>
            <element key="email" value="test@test.nl"/>
            <element key="role" value="lead"/>
        </element>
    </mapping>
</pearpkg>

                                         Deploying PHP applications with Phing – 26 / 37
Packaging


 Then build a TAR

<tar compression="gzip" destFile="package.tgz"
    basedir="build"/>

 ... or ZIP

<zip destfile="htmlfiles.zip">
    <fileset dir=".">
        <include name="**/*.html"/>
    </fileset>
</zip>




                                        Deploying PHP applications with Phing – 27 / 37
Deployment


 SSH

<scp username="john" password="smith"
    host="webserver" todir="/www/htdocs/project/">
    <fileset dir="test">
        <include name="*.html"/>
    </fileset>
</scp>

 FTP

<ftpdeploy
    host="server01"
    username="john"
    password="smit"
    dir="/var/www">
    <fileset dir=".">
        <include name="*.html"/>
    </fileset>
</ftpdeploy>
                                        Deploying PHP applications with Phing – 28 / 37
Extending Phing




                  Deploying PHP applications with Phing – 29 / 37
Extending Phing


Numerous extension points

    Tasks
    Types
    Selectors
    Filters
    Mappers
    Loggers
    ...




                            Deploying PHP applications with Phing – 30 / 37
Sample Task


<?

class SampleTask extends Task
{
    private $var;

     public function setVar($v)
     {
         $this->var = $v;
     }

     public function main()
     {
         $this->log("value: " . $this->var);
     }
}




                                         Deploying PHP applications with Phing – 31 / 37
Sample Task


<project name="Example" default="default">
    <taskdef name="sample"
        classpath="/dev/src"
        classname="tasks.my.SampleTask" />

    <target name="default">
      <sample var="Hello World" />
    </target>
</project>




                                        Deploying PHP applications with Phing – 32 / 37
Ad Hoc Extension


 Dene a task within your build le

<target name="main">
    <adhoc-task name="foo"><![CDATA[
    class FooTest extends Task {
        private $bar;

         function setBar($bar) {
             $this->bar = $bar;
         }

         function main() {
             $this->log("In FooTest: " . $this->bar);
         }
    }
    ]]></adhoc-task>
    <foo bar="TEST"/>
</target>



                                         Deploying PHP applications with Phing – 33 / 37
Demo




       Deploying PHP applications with Phing – 34 / 37
More Uses For Phing


Installations and upgrades

Bootstrapping development environments

Code analysis

Version control (SVN / GIT)

Code encryption / encoding




                                         Deploying PHP applications with Phing – 35 / 37
More Uses For Phing


Installations and upgrades

Bootstrapping development environments

Code analysis

Version control (SVN / GIT)

Code encryption / encoding

Check the documentation!




                                         Deploying PHP applications with Phing – 35 / 37
The Future


Improvements

     Better performance
     Increased test coverage
     Cross-platform compatibility
     Pain-free installation of dependencies (PHAR?)
     More documentation
     IDE support
     Moving to GitHub

We would love (more) contributions!




                                                Deploying PHP applications with Phing – 36 / 37
Questions?




http://www.phing.info

http://joind.in/3590

   #phing (freenode)

     @phingofcial

      Thank you!




                       Deploying PHP applications with Phing – 37 / 37

More Related Content

PDF
Building and deploying PHP applications with Phing
PPTX
PrĂŠsentation de git
PDF
Clouds and Tools: Cheat Sheets & Infographics
PDF
Advanced Git
PPT
Unix/Linux Basic Commands and Shell Script
PPTX
Extreme Replication - Performance Tuning Oracle GoldenGate
PDF
Deep Dive AdminP Process - Admin and Infrastructure Track at UKLUG 2012
PDF
Administração de Redes Linux - II
Building and deploying PHP applications with Phing
PrĂŠsentation de git
Clouds and Tools: Cheat Sheets & Infographics
Advanced Git
Unix/Linux Basic Commands and Shell Script
Extreme Replication - Performance Tuning Oracle GoldenGate
Deep Dive AdminP Process - Admin and Infrastructure Track at UKLUG 2012
Administração de Redes Linux - II

What's hot (20)

PDF
Formation autour de git et git lab
PPT
Git l'essentiel
PPT
Git workflows presentation
PDF
[오픈소스컨설팅]레드햇계열리눅스7 운영자가이드 - 기초편
PDF
Git slides
PPTX
PPTX
Versioning avec Git
PPTX
Introduction 2 linux
PPTX
Git undo
PPTX
GIT In Detail
PDF
nexus helm 설치, docker/helm repo 설정과 예제
PDF
GIT | Distributed Version Control System
PDF
A Practical Introduction to git
PDF
Getting the most out of your Oracle 12.2 Optimizer (i.e. The Brain)
PPTX
Reverse proxy & web cache with NGINX, HAProxy and Varnish
PPTX
Source control
PPTX
.NETからActive Directoryデータにアクセス ~グループ情報の取得と表示~
PDF
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...
PDF
Social Media Monitoring with NiFi, Druid and Superset
Formation autour de git et git lab
Git l'essentiel
Git workflows presentation
[오픈소스컨설팅]레드햇계열리눅스7 운영자가이드 - 기초편
Git slides
Versioning avec Git
Introduction 2 linux
Git undo
GIT In Detail
nexus helm 설치, docker/helm repo 설정과 예제
GIT | Distributed Version Control System
A Practical Introduction to git
Getting the most out of your Oracle 12.2 Optimizer (i.e. The Brain)
Reverse proxy & web cache with NGINX, HAProxy and Varnish
Source control
.NETからActive Directoryデータにアクセス ~グループ情報の取得と表示~
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...
Social Media Monitoring with NiFi, Druid and Superset
Ad

Viewers also liked (20)

ODP
Phing - A PHP Build Tool (An Introduction)
PDF
Phing
PDF
Phing: Building with PHP
 
PDF
Practical PHP Deployment with Jenkins
PDF
Building and Deploying PHP Apps Using phing
PDF
One click deployment with Jenkins - PHP Munich
PDF
Desplegando código con Phing, PHPunit, Coder y Jenkins
KEY
Ant vs Phing
PDF
Smarty Template Engine
PDF
Smarty + PHP
PDF
CIS13: Dealing with Our App-Centric Future
PDF
jQuery fßr Anfänger
PDF
CQRS & Event Sourcing in the wild (ScotlandPHP 2016)
PDF
Putting Phing to Work for You
 
PDF
Introduction Ă  l'intĂŠgration continue en PHP
PPTX
Automated Deployment With Phing
PDF
Framework Auswahlkriterin, PHP Unconference 2009 in Hamburg
PDF
Ain't Nobody Got Time For That: Intro to Automation
PPT
Getting Started With Jenkins And Drupal
PDF
Juc boston2014.pptx
Phing - A PHP Build Tool (An Introduction)
Phing
Phing: Building with PHP
 
Practical PHP Deployment with Jenkins
Building and Deploying PHP Apps Using phing
One click deployment with Jenkins - PHP Munich
Desplegando código con Phing, PHPunit, Coder y Jenkins
Ant vs Phing
Smarty Template Engine
Smarty + PHP
CIS13: Dealing with Our App-Centric Future
jQuery fßr Anfänger
CQRS & Event Sourcing in the wild (ScotlandPHP 2016)
Putting Phing to Work for You
 
Introduction Ă  l'intĂŠgration continue en PHP
Automated Deployment With Phing
Framework Auswahlkriterin, PHP Unconference 2009 in Hamburg
Ain't Nobody Got Time For That: Intro to Automation
Getting Started With Jenkins And Drupal
Juc boston2014.pptx
Ad

Similar to Deploying PHP applications with Phing (20)

PDF
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
PPT
John's Top PECL Picks
ODP
PHP and PDFLib
PPTX
Applying software engineering to configuration management
PPTX
Advanced Malware Analysis Training Session 5 - Reversing Automation
PPT
Build Automation of PHP Applications
PDF
Improving qa on php projects
PDF
Building and Deploying PHP apps with Phing
PPT
Php ppt
PPS
Simplify your professional web development with symfony
PPTX
Build Your First SharePoint Framework Webpart
PDF
Building com Phing - 7Masters PHP
PDF
Lean Php Presentation
PDF
The Beauty And The Beast Php N W09
PDF
Taking Your FDM Application to the Next Level with Advanced Scripting
PPT
Php Development Stack
PPT
Php Development Stack
PDF
IzPack at LyonJUG'11
PDF
Introducing DeploYii 0.5
PDF
Building Web Applications with Zend Framework
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
John's Top PECL Picks
PHP and PDFLib
Applying software engineering to configuration management
Advanced Malware Analysis Training Session 5 - Reversing Automation
Build Automation of PHP Applications
Improving qa on php projects
Building and Deploying PHP apps with Phing
Php ppt
Simplify your professional web development with symfony
Build Your First SharePoint Framework Webpart
Building com Phing - 7Masters PHP
Lean Php Presentation
The Beauty And The Beast Php N W09
Taking Your FDM Application to the Next Level with Advanced Scripting
Php Development Stack
Php Development Stack
IzPack at LyonJUG'11
Introducing DeploYii 0.5
Building Web Applications with Zend Framework

Recently uploaded (20)

PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Advanced Soft Computing BINUS July 2025.pdf
PPTX
Cloud computing and distributed systems.
PDF
Empathic Computing: Creating Shared Understanding
PDF
Advanced IT Governance
PDF
NewMind AI Weekly Chronicles - August'25 Week I
DOCX
The AUB Centre for AI in Media Proposal.docx
 
PDF
Modernizing your data center with Dell and AMD
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
cuic standard and advanced reporting.pdf
PPT
Teaching material agriculture food technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
GamePlan Trading System Review: Professional Trader's Honest Take
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Advanced Soft Computing BINUS July 2025.pdf
Cloud computing and distributed systems.
Empathic Computing: Creating Shared Understanding
Advanced IT Governance
NewMind AI Weekly Chronicles - August'25 Week I
The AUB Centre for AI in Media Proposal.docx
 
Modernizing your data center with Dell and AMD
Spectral efficient network and resource selection model in 5G networks
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
madgavkar20181017ppt McKinsey Presentation.pdf
cuic standard and advanced reporting.pdf
Teaching material agriculture food technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Sensors and Actuators in IoT Systems using pdf
Per capita expenditure prediction using model stacking based on satellite ima...

Deploying PHP applications with Phing

  • 1. Deploying PHP applications with Phing Michiel Rook PHPNW11 - October 8th, 2011 Deploying PHP applications with Phing – 1 / 37
  • 2. About me Freelance PHP/Java consultant Phing project lead http://www.linkedin.com/in/michieltcs @michieltcs Deploying PHP applications with Phing – 2 / 37
  • 3. About Phing PHing Is Not GNU make; it’s a PHP project build system or build tool based on Apache Ant. Originally developed by Binarycloud Ported to PHP5 by Hans Lellelid I joined in 2005 Deploying PHP applications with Phing – 3 / 37
  • 4. Features Scripting using XML build les Mostly cross-platform Interface to various popular (PHP) tools Deploying PHP applications with Phing – 4 / 37
  • 5. Features Deploying PHP applications with Phing – 5 / 37
  • 6. Installation PEAR installation $ pear channel-discover pear.phing.info $ pear install [--alldeps] phing/phing Optionally, install the documentation package $ pear install phing/phingdocs Deploying PHP applications with Phing – 6 / 37
  • 7. Why Use A Build Tool? Deploying PHP applications with Phing – 7 / 37
  • 8. Why Use A Build Tool Repetitive tasks Version control (Unit) Testing Conguring Packaging Uploading DB changes ... Deploying PHP applications with Phing – 8 / 37
  • 9. Why Use A Build Tool For developers and administrators Automate! Easier handover to new team members Improves quality Reduces errors Saves time Deploying PHP applications with Phing – 9 / 37
  • 10. Why Use Phing Rich set of tasks Integration with PHP specic tools Allows you to stay in the PHP infrastructure Easy to extend Embed PHP code directly in the build le Deploying PHP applications with Phing – 10 / 37
  • 11. Why Use Phing Rich set of tasks Integration with PHP specic tools Allows you to stay in the PHP infrastructure Easy to extend Embed PHP code directly in the build le ... in the end, the choice is yours Deploying PHP applications with Phing – 10 / 37
  • 12. The Basics Deploying PHP applications with Phing – 11 / 37
  • 13. Build Files Phing uses XML build les Contain standard elements Task: code that performs a specic function (svn checkout, mkdir, etc.) Target: groups of tasks, can optionally depend on other targets Project: root node, contains multiple targets Deploying PHP applications with Phing – 12 / 37
  • 14. Example Build File <project name="Example" default="world"> <target name="hello"> <echo>Hello</echo> </target> <target name="world" depends="hello"> <echo>World!</echo> </target> </project> Deploying PHP applications with Phing – 13 / 37
  • 15. Properties Simple key-value les (.ini) ## build.properties version=1.0 Can be expanded by using ${key} in the build le $ phing -propertyfile build.properties ... <project name="Example" default="default"> <property file="build.properties" /> <target name="default"> <echo>${version}</echo> </target> </project> Deploying PHP applications with Phing – 14 / 37
  • 16. File Sets Constructs a group of les to process Supported by most tasks <fileset dir="./application" includes="**"/> <fileset dir="./application"> <include name="**/*.php" /> <exclude name="**/*Test.php" /> </fileset> Supports references <fileset dir="./application" includes="**" id="files"/> <fileset refid="files"/> Deploying PHP applications with Phing – 15 / 37
  • 17. File Sets Selectors allow ne-grained matching on certain attributes contains, date, le name & size, ... <fileset dir="${dist}"> <and> <filename name="**"/> <date datetime="01/01/2011" when="before"/> </and> </fileset> Deploying PHP applications with Phing – 16 / 37
  • 18. Mappers and Filters Transform les during copy/move/... Mappers Change lename Filters Strip comments, white space Replace values Perform XSLT transformation Translation (i18n) Deploying PHP applications with Phing – 17 / 37
  • 19. Mappers and Filters <copy todir="${build}"> <fileset refid="files"/> <mapper type="glob" from="*.txt" to="*.new.txt"/> <filterchain> <replaceregexp> <regexp pattern="rn" replace="n"/> <expandproperties/> </replaceregexp> </filterchain> </copy> Deploying PHP applications with Phing – 18 / 37
  • 20. Practical Examples Deploying PHP applications with Phing – 19 / 37
  • 21. Testing Built-in support for PHPUnit / SimpleTest Code coverage through XDebug Various output formats Deploying PHP applications with Phing – 20 / 37
  • 22. PHPUnit <target name="test"> <coverage-setup database="reports/coverage.db"> <fileset dir="src"> <include name="**/*.php"/> <exclude name="**/*Test.php"/> </fileset> </coverage-setup> <phpunit codecoverage="true"> <formatter type="xml" todir="reports"/> <batchtest> <fileset dir="src"> <include name="**/*Test.php"/> </fileset> </batchtest> </phpunit> <phpunitreport infile="reports/testsuites.xml" format="frames" todir="reports/tests"/> <coverage-report outfile="reports/coverage.xml"> <report todir="reports/coverage" title="Demo"/> </coverage-report> </target> Deploying PHP applications with Phing – 21 / 37
  • 23. DocBlox <target name="docs"> <docblox title="Phing API Documentation" output="docs" quiet="true"> <fileset dir="../../classes"> <include name="**/*.php"/> </fileset> </docblox> </target> Deploying PHP applications with Phing – 22 / 37
  • 24. Database Migration DbDeploy Set of delta les (SQL) Tracks current version in changelog table Generates do & undo scripts Deploying PHP applications with Phing – 23 / 37
  • 25. Database Migration Numbered delta le (1-create-post.sql) Apply & undo statements --// CREATE TABLE ‘post‘ ( ‘title‘ VARCHAR(255), ‘time_created‘ DATETIME, ‘content‘ MEDIUMTEXT ); --//@UNDO DROP TABLE ‘post‘; --// Deploying PHP applications with Phing – 24 / 37
  • 26. Database Migration <target name="migrate"> <dbdeploy url="sqlite:test.db" dir="deltas" outputfile="deploy.sql" undooutputfile="undo.sql"/> <pdosqlexec src="deploy.sql" url="sqlite:test.db"/> </target> Deploying PHP applications with Phing – 25 / 37
  • 27. Packaging Create complete PEAR packages <pearpkg name="demo" dir="."> <fileset refid="files"/> <option name="outputdirectory" value="./build"/> <option name="description">Test package</option> <option name="version" value="0.1.0"/> <option name="state" value="beta"/> <mapping name="maintainers"> <element> <element key="handle" value="test"/> <element key="name" value="Test"/> <element key="email" value="[email protected]"/> <element key="role" value="lead"/> </element> </mapping> </pearpkg> Deploying PHP applications with Phing – 26 / 37
  • 28. Packaging Then build a TAR <tar compression="gzip" destFile="package.tgz" basedir="build"/> ... or ZIP <zip destfile="htmlfiles.zip"> <fileset dir="."> <include name="**/*.html"/> </fileset> </zip> Deploying PHP applications with Phing – 27 / 37
  • 29. Deployment SSH <scp username="john" password="smith" host="webserver" todir="/www/htdocs/project/"> <fileset dir="test"> <include name="*.html"/> </fileset> </scp> FTP <ftpdeploy host="server01" username="john" password="smit" dir="/var/www"> <fileset dir="."> <include name="*.html"/> </fileset> </ftpdeploy> Deploying PHP applications with Phing – 28 / 37
  • 30. Extending Phing Deploying PHP applications with Phing – 29 / 37
  • 31. Extending Phing Numerous extension points Tasks Types Selectors Filters Mappers Loggers ... Deploying PHP applications with Phing – 30 / 37
  • 32. Sample Task <? class SampleTask extends Task { private $var; public function setVar($v) { $this->var = $v; } public function main() { $this->log("value: " . $this->var); } } Deploying PHP applications with Phing – 31 / 37
  • 33. Sample Task <project name="Example" default="default"> <taskdef name="sample" classpath="/dev/src" classname="tasks.my.SampleTask" /> <target name="default"> <sample var="Hello World" /> </target> </project> Deploying PHP applications with Phing – 32 / 37
  • 34. Ad Hoc Extension Dene a task within your build le <target name="main"> <adhoc-task name="foo"><![CDATA[ class FooTest extends Task { private $bar; function setBar($bar) { $this->bar = $bar; } function main() { $this->log("In FooTest: " . $this->bar); } } ]]></adhoc-task> <foo bar="TEST"/> </target> Deploying PHP applications with Phing – 33 / 37
  • 35. Demo Deploying PHP applications with Phing – 34 / 37
  • 36. More Uses For Phing Installations and upgrades Bootstrapping development environments Code analysis Version control (SVN / GIT) Code encryption / encoding Deploying PHP applications with Phing – 35 / 37
  • 37. More Uses For Phing Installations and upgrades Bootstrapping development environments Code analysis Version control (SVN / GIT) Code encryption / encoding Check the documentation! Deploying PHP applications with Phing – 35 / 37
  • 38. The Future Improvements Better performance Increased test coverage Cross-platform compatibility Pain-free installation of dependencies (PHAR?) More documentation IDE support Moving to GitHub We would love (more) contributions! Deploying PHP applications with Phing – 36 / 37
  • 39. Questions? http://www.phing.info http://joind.in/3590 #phing (freenode) @phingofcial Thank you! Deploying PHP applications with Phing – 37 / 37