SlideShare une entreprise Scribd logo
1  sur  39
Télécharger pour lire hors ligne
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 files

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
     Configuring
     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 specific tools

Allows you to stay in the PHP infrastructure

Easy to extend

Embed PHP code directly in the build file




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


Rich set of tasks

Integration with PHP specific tools

Allows you to stay in the PHP infrastructure

Easy to extend

Embed PHP code directly in the build file

... 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 files

Contain standard elements

     Task: code that performs a specific 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 files (.ini)

## build.properties
version=1.0

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

$ 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 files 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 fine-grained matching on certain attributes

 contains, date, file 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 files during copy/move/...

Mappers

      Change filename

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 files (SQL)

Tracks current version in changelog table

Generates do & undo scripts




                                            Deploying PHP applications with Phing – 23 / 37
Database Migration


 Numbered delta file (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


 Define a task within your build file

<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)

     @phingofficial

      Thank you!




                       Deploying PHP applications with Phing – 37 / 37

Contenu connexe

Tendances

Nginx Internals
Nginx InternalsNginx Internals
Nginx InternalsJoshua Zhu
 
Phing: Building with PHP
Phing: Building with PHPPhing: Building with PHP
Phing: Building with PHPhozn
 
Autoscaling with hashi_corp_nomad
Autoscaling with hashi_corp_nomadAutoscaling with hashi_corp_nomad
Autoscaling with hashi_corp_nomadBram Vogelaar
 
Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsAdam Culp
 
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹InfraEngineer
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Omar Fathy
 
Giới thiệu docker và ứng dụng trong ci-cd
Giới thiệu docker và ứng dụng trong ci-cdGiới thiệu docker và ứng dụng trong ci-cd
Giới thiệu docker và ứng dụng trong ci-cdGMO-Z.com Vietnam Lab Center
 
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?ArangoDB Database
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubJasleenSondhi
 
Présentation Git & GitHub
Présentation Git & GitHubPrésentation Git & GitHub
Présentation Git & GitHubThibault Vlacich
 
Git flow for daily use
Git flow for daily useGit flow for daily use
Git flow for daily useMediacurrent
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016Frans Rosén
 

Tendances (20)

Nginx Internals
Nginx InternalsNginx Internals
Nginx Internals
 
PIC your malware
PIC your malwarePIC your malware
PIC your malware
 
Phing: Building with PHP
Phing: Building with PHPPhing: Building with PHP
Phing: Building with PHP
 
Autoscaling with hashi_corp_nomad
Autoscaling with hashi_corp_nomadAutoscaling with hashi_corp_nomad
Autoscaling with hashi_corp_nomad
 
Offzone | Another waf bypass
Offzone | Another waf bypassOffzone | Another waf bypass
Offzone | Another waf bypass
 
Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with Jenkins
 
The Hacker's Guide to Kubernetes
The Hacker's Guide to KubernetesThe Hacker's Guide to Kubernetes
The Hacker's Guide to Kubernetes
 
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
 
Maven
MavenMaven
Maven
 
Giới thiệu docker và ứng dụng trong ci-cd
Giới thiệu docker và ứng dụng trong ci-cdGiới thiệu docker và ứng dụng trong ci-cd
Giới thiệu docker và ứng dụng trong ci-cd
 
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Présentation Git & GitHub
Présentation Git & GitHubPrésentation Git & GitHub
Présentation Git & GitHub
 
Git training v10
Git training v10Git training v10
Git training v10
 
Git flow for daily use
Git flow for daily useGit flow for daily use
Git flow for daily use
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
 

En vedette

Building and deploying PHP applications with Phing
Building and deploying PHP applications with PhingBuilding and deploying PHP applications with Phing
Building and deploying PHP applications with PhingMichiel Rook
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Michiel Rook
 
Building and Deploying PHP Apps Using phing
Building and Deploying PHP Apps Using phingBuilding and Deploying PHP Apps Using phing
Building and Deploying PHP Apps Using phingMihail Irintchev
 
One click deployment with Jenkins - PHP Munich
One click deployment with Jenkins - PHP MunichOne click deployment with Jenkins - PHP Munich
One click deployment with Jenkins - PHP MunichMayflower GmbH
 
Desplegando código con Phing, PHPunit, Coder y Jenkins
Desplegando código con Phing, PHPunit, Coder y JenkinsDesplegando código con Phing, PHPunit, Coder y Jenkins
Desplegando código con Phing, PHPunit, Coder y JenkinsLa Drupalera
 
CIS13: Dealing with Our App-Centric Future
CIS13: Dealing with Our App-Centric FutureCIS13: Dealing with Our App-Centric Future
CIS13: Dealing with Our App-Centric FutureCloudIDSummit
 
CQRS & Event Sourcing in the wild (ScotlandPHP 2016)
CQRS & Event Sourcing in the wild (ScotlandPHP 2016)CQRS & Event Sourcing in the wild (ScotlandPHP 2016)
CQRS & Event Sourcing in the wild (ScotlandPHP 2016)Michiel Rook
 
Putting Phing to Work for You
Putting Phing to Work for YouPutting Phing to Work for You
Putting Phing to Work for Youhozn
 
Introduction à l'intégration continue en PHP
Introduction à l'intégration continue en PHPIntroduction à l'intégration continue en PHP
Introduction à l'intégration continue en PHPEric Hogue
 
Automated Deployment With Phing
Automated Deployment With PhingAutomated Deployment With Phing
Automated Deployment With PhingDaniel Cousineau
 
Framework Auswahlkriterin, PHP Unconference 2009 in Hamburg
Framework Auswahlkriterin, PHP Unconference 2009 in Hamburg Framework Auswahlkriterin, PHP Unconference 2009 in Hamburg
Framework Auswahlkriterin, PHP Unconference 2009 in Hamburg Ralf Eggert
 
Ain't Nobody Got Time For That: Intro to Automation
Ain't Nobody Got Time For That: Intro to AutomationAin't Nobody Got Time For That: Intro to Automation
Ain't Nobody Got Time For That: Intro to Automationmfrost503
 
Getting Started With Jenkins And Drupal
Getting Started With Jenkins And DrupalGetting Started With Jenkins And Drupal
Getting Started With Jenkins And DrupalPhilip Norton
 
Build & deploy PHP application (intro level)
Build & deploy PHP application (intro level)Build & deploy PHP application (intro level)
Build & deploy PHP application (intro level)Anton Babenko
 

En vedette (20)

Building and deploying PHP applications with Phing
Building and deploying PHP applications with PhingBuilding and deploying PHP applications with Phing
Building and deploying PHP applications with Phing
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
 
Phing
PhingPhing
Phing
 
Building and Deploying PHP Apps Using phing
Building and Deploying PHP Apps Using phingBuilding and Deploying PHP Apps Using phing
Building and Deploying PHP Apps Using phing
 
One click deployment with Jenkins - PHP Munich
One click deployment with Jenkins - PHP MunichOne click deployment with Jenkins - PHP Munich
One click deployment with Jenkins - PHP Munich
 
Desplegando código con Phing, PHPunit, Coder y Jenkins
Desplegando código con Phing, PHPunit, Coder y JenkinsDesplegando código con Phing, PHPunit, Coder y Jenkins
Desplegando código con Phing, PHPunit, Coder y Jenkins
 
Ant vs Phing
Ant vs PhingAnt vs Phing
Ant vs Phing
 
Smarty Template Engine
Smarty Template EngineSmarty Template Engine
Smarty Template Engine
 
Smarty + PHP
Smarty + PHPSmarty + PHP
Smarty + PHP
 
CIS13: Dealing with Our App-Centric Future
CIS13: Dealing with Our App-Centric FutureCIS13: Dealing with Our App-Centric Future
CIS13: Dealing with Our App-Centric Future
 
jQuery für Anfänger
jQuery für AnfängerjQuery für Anfänger
jQuery für Anfänger
 
CQRS & Event Sourcing in the wild (ScotlandPHP 2016)
CQRS & Event Sourcing in the wild (ScotlandPHP 2016)CQRS & Event Sourcing in the wild (ScotlandPHP 2016)
CQRS & Event Sourcing in the wild (ScotlandPHP 2016)
 
Putting Phing to Work for You
Putting Phing to Work for YouPutting Phing to Work for You
Putting Phing to Work for You
 
Introduction à l'intégration continue en PHP
Introduction à l'intégration continue en PHPIntroduction à l'intégration continue en PHP
Introduction à l'intégration continue en PHP
 
Automated Deployment With Phing
Automated Deployment With PhingAutomated Deployment With Phing
Automated Deployment With Phing
 
Framework Auswahlkriterin, PHP Unconference 2009 in Hamburg
Framework Auswahlkriterin, PHP Unconference 2009 in Hamburg Framework Auswahlkriterin, PHP Unconference 2009 in Hamburg
Framework Auswahlkriterin, PHP Unconference 2009 in Hamburg
 
Ain't Nobody Got Time For That: Intro to Automation
Ain't Nobody Got Time For That: Intro to AutomationAin't Nobody Got Time For That: Intro to Automation
Ain't Nobody Got Time For That: Intro to Automation
 
Getting Started With Jenkins And Drupal
Getting Started With Jenkins And DrupalGetting Started With Jenkins And Drupal
Getting Started With Jenkins And Drupal
 
Juc boston2014.pptx
Juc boston2014.pptxJuc boston2014.pptx
Juc boston2014.pptx
 
Build & deploy PHP application (intro level)
Build & deploy PHP application (intro level)Build & deploy PHP application (intro level)
Build & deploy PHP application (intro level)
 

Similaire à Deploying PHP applications with Phing

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
 
PHP and PDFLib
PHP and PDFLibPHP and PDFLib
PHP and PDFLibAdam Culp
 
Applying software engineering to configuration management
Applying software engineering to configuration managementApplying software engineering to configuration management
Applying software engineering to configuration managementBart Vanbrabant
 
Advanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing AutomationAdvanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing Automationsecurityxploded
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP ApplicationsPavan Kumar N
 
Building and Deploying PHP apps with Phing
Building and Deploying PHP apps with PhingBuilding and Deploying PHP apps with Phing
Building and Deploying PHP apps with PhingMichiel Rook
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfonyFrancois Zaninotto
 
Build Your First SharePoint Framework Webpart
Build Your First SharePoint Framework WebpartBuild Your First SharePoint Framework Webpart
Build Your First SharePoint Framework WebpartEric Overfield
 
Building com Phing - 7Masters PHP
Building com Phing - 7Masters PHPBuilding com Phing - 7Masters PHP
Building com Phing - 7Masters PHPiMasters
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php PresentationAlan Pinstein
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09Bastian Feder
 
Taking Your FDM Application to the Next Level with Advanced Scripting
Taking Your FDM Application to the Next Level with Advanced ScriptingTaking Your FDM Application to the Next Level with Advanced Scripting
Taking Your FDM Application to the Next Level with Advanced ScriptingAlithya
 
Php Development Stack
Php Development StackPhp Development Stack
Php Development Stackshah_neeraj
 
IzPack at LyonJUG'11
IzPack at LyonJUG'11IzPack at LyonJUG'11
IzPack at LyonJUG'11julien.ponge
 
Introducing DeploYii 0.5
Introducing DeploYii 0.5Introducing DeploYii 0.5
Introducing DeploYii 0.5Giovanni Derks
 
Building Web Applications with Zend Framework
Building Web Applications with Zend FrameworkBuilding Web Applications with Zend Framework
Building Web Applications with Zend FrameworkPhil Brown
 

Similaire à Deploying PHP applications with Phing (20)

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-)
 
John's Top PECL Picks
John's Top PECL PicksJohn's Top PECL Picks
John's Top PECL Picks
 
PHP and PDFLib
PHP and PDFLibPHP and PDFLib
PHP and PDFLib
 
Applying software engineering to configuration management
Applying software engineering to configuration managementApplying software engineering to configuration management
Applying software engineering to configuration management
 
Advanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing AutomationAdvanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing Automation
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
 
Improving qa on php projects
Improving qa on php projectsImproving qa on php projects
Improving qa on php projects
 
Building and Deploying PHP apps with Phing
Building and Deploying PHP apps with PhingBuilding and Deploying PHP apps with Phing
Building and Deploying PHP apps with Phing
 
Php ppt
Php pptPhp ppt
Php ppt
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Build Your First SharePoint Framework Webpart
Build Your First SharePoint Framework WebpartBuild Your First SharePoint Framework Webpart
Build Your First SharePoint Framework Webpart
 
Building com Phing - 7Masters PHP
Building com Phing - 7Masters PHPBuilding com Phing - 7Masters PHP
Building com Phing - 7Masters PHP
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09
 
Taking Your FDM Application to the Next Level with Advanced Scripting
Taking Your FDM Application to the Next Level with Advanced ScriptingTaking Your FDM Application to the Next Level with Advanced Scripting
Taking Your FDM Application to the Next Level with Advanced Scripting
 
Php Development Stack
Php Development StackPhp Development Stack
Php Development Stack
 
Php Development Stack
Php Development StackPhp Development Stack
Php Development Stack
 
IzPack at LyonJUG'11
IzPack at LyonJUG'11IzPack at LyonJUG'11
IzPack at LyonJUG'11
 
Introducing DeploYii 0.5
Introducing DeploYii 0.5Introducing DeploYii 0.5
Introducing DeploYii 0.5
 
Building Web Applications with Zend Framework
Building Web Applications with Zend FrameworkBuilding Web Applications with Zend Framework
Building Web Applications with Zend Framework
 

Dernier

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Dernier (20)

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 

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 files 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 Configuring 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 specific tools Allows you to stay in the PHP infrastructure Easy to extend Embed PHP code directly in the build file Deploying PHP applications with Phing – 10 / 37
  • 11. Why Use Phing Rich set of tasks Integration with PHP specific tools Allows you to stay in the PHP infrastructure Easy to extend Embed PHP code directly in the build file ... 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 files Contain standard elements Task: code that performs a specific 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 files (.ini) ## build.properties version=1.0 Can be expanded by using ${key} in the build file $ 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 files 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 fine-grained matching on certain attributes contains, date, file 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 files during copy/move/... Mappers Change filename 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 files (SQL) Tracks current version in changelog table Generates do & undo scripts Deploying PHP applications with Phing – 23 / 37
  • 25. Database Migration Numbered delta file (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="test@test.nl"/> <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 Define a task within your build file <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) @phingofficial Thank you! Deploying PHP applications with Phing – 37 / 37