SlideShare a Scribd company logo
USING PHING
FOR FUN AND
PROFIT
PHING: A PHP BUILD SYSTEM
Nic Jansma
nicj.net
@NicJ
PHING

Phing is a cross-platform PHP build tool, similar to Apache
Ant.
WHAT IS A BUILD TOOL?
A build tool helps you automate repetitive tasks.
A BUILD TOOL HELPS
YOU...

Build resources (CSS, JavaScript, templates, etc)
Validate code (lint, sniff, etc)
Run unit tests
Build documentation
Create packages
Deploy code
Execute system commands
... and anything else you do repetitively ...
WHY USE A BUILD TOOL?

Otherwise you will f*** up.
You should automate everything you can.
Automating your processes will save you time.
Automating your processes will save you from your future
self.
Maybe not today, maybe not tomorrow, but at some point
you will make a mistake if it's not automated.
WHY USE PHING?

It's written in PHP, so if the rest of your project is PHP, you
can run Phing.
Besides PHP, no other external dependencies are needed
(such as Ruby or Java).
Great community support, with hundreds of different tasks.
INSTALLATION - GITHUB
github.com/phingofficial/phing

$ gt c oe ht s / gt u .o /h no fc a /h n. i
> i l n tp : /i hb cm p ig fi il pi g gt
$ pp p ig bn pi g
> h h n i h n
INSTALLATION - PHAR
PACKAGE
www.phing.info/trac/wiki/Users/Download

$ w e h t : / w . h n . n o g t p i g l t s . h r - p i gp a
> g t tp /w wp ig i f / e/ hn -a e tp a O hn .h r
$ pp p ig pa
> h h n. hr
INSTALLATION - PEAR
$ pa c an ld s oe p a. hn .n o
> e r hn e- ic vr e rp i gi f
$ pa i sa lp i gp ig
> e r nt l hn /h n
$ pi g
> hn
INSTALLATION COMPOSER
composer.json:

{
" eu r" {
r q ie :
"hn /h n " " . ."
pi gp ig : 26 1
}
}

$ pp c mo e. hr is a l
> h o ps rp a n tl
L ai gc mo e rp st r e w t pc ae i fr ai n
o dn op sr e oi oi s ih a kg n om t o
I sa ln d pn ec e (n ld n rq ie d v
n tl i g e ed n is i cu ig e ur -e )
-I sa ln p ig pi g (. .)
n t li g h n/h n 26 1
D wl ai g 10
o n od n: 0 %
W ii gl c fl
r tn ok ie
G nr tn a tl a fl s
e ea i g u oo d ie
$ pp v no h n hn  i hn
> h e dr pi g pi g b np i g
PHING OVERVIEW

Phing is driven by XML files that define your projects, build
targets, and individual tasks.
The XML format is very similar to Apache Ant.
PHING - PROJECTS

A project is the root element of your XML.
The < r j c >defines of all of your build targets and the
poet
tasks that will execute for the targets.
Only the d f u tattribut is required, which specifies the
eal
default target to run.
< xl vr in ". " ec dn =U F 8?
? m e so =1 0 no i g" T- ">
< rj c nm =m -r jc " df ut "u l"
p oe t ae "y p oe t ea l =b id >
< - tr es ad ts s ->
! - ag t n a k < - .. ->
!- . <po et
/rj c >
PHING - TARGETS

A < a g t is a logical set of actions you want to take.
tre>
A < a g t can have tasks.
tre>
A < a g t can also have a list of other targets it depends
tre>
on.
< xl vr in ". " ec dn =U F 8?
? m e so =1 0 no i g" T- ">
< rj c nm =m -r jc " df ut "u l"
p oe t ae "y p oe t ea l =b id >
< ag tn m=b id d pn s" la ,i t mn f"/
t r e ae"u l" e ed = ce nl n, ii y >
< ag tn m=c en >
t r e ae"l a"
<co mg " ' c e nn y u b id /
eh s =I m la ig o r ul " >
<tr e >
/a gt
< - .. ->
!- . <po et
/rj c >
PHING - TASKS

A task will take an action.
Tasks can be a core task that Phing ships with, or an external
plug-in that you write.
< xl vr in ". " ec dn =U F 8?
? m e so =1 0 no i g" T- ">
< rj c nm =m -r jc " df ut "u l"
p oe t ae "y p oe t ea l =b id >
< ag tn m=c en >
t r e ae"l a"
<co mg " ' c e nn y u b id /
eh s =I m la ig o r ul " >
<ee e d r"u l" /
dl t i=bi d >
<tr e >
/a gt
<po et
/rj c >
PHING - CORE TASKS

123 built-in tasks.
Some of the most useful:
File operations: a p n , c p , d l t , m d r
ped oy eee ki
Conditional logic: c n i i n f r a h i , f i
odto, oec, f al
Input / output: e h , i p t
co nu
System: e e , t t m , t s d f
xc sap ake
Source control: g t , s n , c s
i* v* v*
Network: f p e l y h t g t m i , s p t s p s h
tdpo, tpe, al 3u, c, s
External Libraries: p p o e n f e , p p n t
hcdsifr hui,
p p o u e t rj l n , p p d
hdcmno, sit hm
PHING - PROPERTIES

A property is a variable.
Properties can come from built-in properties (Phing
environment variables), a b i d p o e t e file, or
ul.rpris
created at runtime in your XML file via the < r p r y
poet>
element.
Use properties via the $ p o e t n m }syntax.
{rpryae
< xl vr in ". " ec dn =U F 8?
? m e so =1 0 no i g" T- ">
< rj c nm =m -r jc " df ut "l a"
p oe t ae "y p oe t ea l =c en >
< rp ry nm = bi di "v l e" /u l" /
p o et a e" ul d r au=. bi d >
< ag tn m=c en >
t r e ae"l a"
<co mg " ' c e nn $ bi di } /
eh s =I m la ig { ul dr " >
<ee e d r"{ ul dr " /
dl t i=$b i di } >
<tr e >
/a gt
<po et
/rj c >
PHING - BUILT-IN
PROPERTIES

There are many built-in properties:
apiainsati,ev* hs.rh
plcto.trdr n., otac,
hs.oan hs.sye hs.ae hs.s
otdmi, otftp, otnm, oto,
hs.srlae hs.svrin
oto.ees, oto.eso,
ln.eaao,o.ae pigfl,
iesprtr snm, hn.ie
pigdr pighm,pigvrin
hn.i, hn.oe hn.eso,
pigpoetnm,ppcasah
hn.rjc.ae h.lspt,
ppvrin poetbsdr ue.oe
h.eso, rjc.aei, srhm
PHING - .PROPERTIES
FILES
Simple k y v l eformat
e=au

#Ti i ac me t i t e .r pr is fl
hs s
om n n h po e te i e
k yv le
e =a u
b id i= ul
u ld r bi d
m ap nm =o
y p. a ef o
m ap ul ht :/ o .o
y p. r =t p/ fo cm

< xl vr in ". " ec dn =U F 8?
? m e so =1 0 no i g" T- ">
< rj c nm =m -r jc " df ut "l a"
p o e t a e " y p o e t e a l =c e n >
< rp ry fl = .b id po e te "/
p o et i e" /u l .r pr is >
< ag tn m= c en >
t r e ae "l a"
< co mg " ' c e nn $ bi di }f r$ m ap nm } /
eh s =I m la ig { ul dr o {y p. a e" >
<ee e d r"{ ul dr " /
dl t i= $b i di } >
< tr e>
/ a gt
< po et
/ rj c>
PHING - < R P R Y
POET>
Define new properties in your XML.
< xl vr in ". " ec dn =U F 8?
? m e so =1 0 no i g" T- ">
< rj c nm =m -r jc " df ut "u l"
p o e t a e " y p o e t e a l =b i d >
< rp ry nm = bi di "v l e" /u l" /
p o et a e" ul d r au =. bi d >
< rp ry nm = cs i"vl e "{ ul }c s /
p o et a e" sd r a u= $b id / s" >
< rp ry nm = jd r vl e"{u l} j "/
p o et a e" si " au =$b id /s >
< ag tn m= c en >
t r e ae "l a"
<ee e d r"{ sd r"/
dl t i= $c s i} >
<ee e d r"{ si } /
dl t i= $j d r" >
< tr e>
/ a gt
< po et
/ rj c>
EXAMPLES
SIMPLE
< xl vr in ". " ec dn =U F 8?
? m e so =1 0 no i g" T- ">
< rj c nm =m -r jc " df ut "c o >
p oe t ae "y p oe t ea l =e h"
< ag tn m=e h"
t r e ae"c o >
<co mg " el "/
eh s =H lo >
<tr e >
/a gt
<po et
/rj c >

> pi geh
$ h n co
B id ie . bi dx l
u lf l :  ul . m
m -r jc > eh :
y po e t
co
[ c o H lo
eh ] el
B ID FN SE
U L I IH D
T tl tm :0 18 s cn s
o a i e .7 0 eo d
TWO TASKS
< xl vr in ". " ec dn =U F 8?
? m e so =1 0 no i g" T- ">
< rj c nm =m -r jc " df ut "i s"
p oe t ae "y p oe t ea l =f rt >
< ag tn m=f rt d pn s" eo d /
t r e ae"i s" e ed = sc n" >
< ag tn m=s cn "
t r e ae"e od >
<al ms a e" o ms e u" /
fi e sg =Y u es d p >
<tr e >
/a gt
<po et
/rj c >

> pi g fr t
$ h n is
B id ie . bi dx l
u lf l:  ul . m
m -r jc > sc n :
y po e t
eo d
E eu in o tr e "e od f ie f rt ef lo i gr ao :
x ct o f ag t sc n " a l d o h ol wn e s n
. bi dx l1: 2 Y u ms e u
 u l. m: 62 : o es d p
B ID FI E
U L A LD
. bi dx l1:2 Y um s e u
 ul . m: 62 : o es d p
T tl tm :0 10 s cn s
o a i e .8 0 eo d
SHELL COMMANDS
< xl vr in ". " ec dn =U F 8?
? m e so =1 0 no i g" T- ">
< rj c nm =m -r jc " df ut "e ly >
p oe t ae "y p oe t ea l =d po "
< rp rynm = dp o. ot a e v le " o. o"/
p o et a e" el y hs nm " au=f oc m >
< ag tn m=d po "
t r e ae"e ly >
<xc
ee
c ma d"s n -v . $d po . ot ae /
om n=ry z az / { el yh sn m }"
d r" { rj c. ae i }
i= $p oe t bs dr "
c ek e un"r e /
hc rt r=t u" >
<tr e >
/a gt
<po et
/rj c >
EXTERNAL PHP
< xl vr in ". " ec dn =U F 8?
? m e so =1 0 no i g" T- ">
< rj c nm =m -r jc " df ut "x en l ak >
p oe t ae "y p oe t ea l =e tr at s"
< ag tn m=e tr at s"
t r e ae"x en l ak >
<ak e
ts df
n m=m po et ak
ae"y rj c ts "
c as a h" {r jc . ae i}
ls pt=$ p oe tb sd r"
c as a e" ya k / <- .M T s. h ->
ls nm=M T s" > !- / ya kp p <yr jc t s m s ae'i /
mp oe ta k es g=h ' >
<tr e >
/a gt
<po et
/rj c >

< pp
?h
r qi eo c 'h n/ ak p p;
e ur _ ne pi g Ts .h '
c as MT s et ns Ts {
l s y ak xe d a k
p oe td $e s g;
r t ce m sa e
/ s tf o t e ts ' at iu ei t eX L
/ e r m h ak s tr b t n h M
p bi f nt o st es g (m sa e {
u l c u ci n eM s ae $e sg )
$ hs>e s g = $ es g;
ti-m sa e
m sa e
}
/ e eu e w e ts i c le
/ x ct d hn a k s a l d
p bi f nt o mi ( {
u l c u ci n an )
e h $h s> es g ;
co ti - ms ae
}
EXTERNAL PHP - OUTPUT
$ pi ge tr at s
> hn xe nl ak
B id ie . bi d x l
u lf l :  ul . m
[ rp r y L ai g .b id po e te
po et ] od n u l .r pr is
m -r jc > et ra ts :
y po e t
xe n la k
h
i
B ID FN SE
U L I IH D
T tl tm :0 23 s cn s
o a i e .9 0 eo d
CONTINUOUS
INTEGRATION / BUILD
SERVER
< xl vr in ". " ec dn =U F 8?
? m e so =1 0 no i g" T- ">
< rj c nm =b gp oe t df u t" ul "
p oe t ae "i - rj c" e al =b id >
< - mi tr e s- >
! - an a gt < ag tn m=b id d pn s" la ,h c ot ln ,
t r e ae"u l" e ed = ce nc ek u, i t
s if pp d ts ,o ,a k g" /
nf ,h m, et d cp ca e >
< ag tn m=d po "d pn s"u l, r- el y ry cr la e /
t r e ae"e ly ee d=bi dp e dp o, sn , ee s" >
< ag tn m=c en >
t r e ae"l a"
< - ce nt eb i d- >
!- la h ul <tr e >
/a gt
< ag tn m=c ek u"
t r e ae"h co t >
< - ce ku / pl l ts f o s u c c n rl ->
!- hc o t
u l a e t r m or e ot o <tr e >
/a gt
< ag tn m=l n" dp ns " hl n, si tc s it /
t r e ae"i t e ed =p pi tj l n, sl n" >
< ag tn m=p pi t>
t r e ae"h ln "
< - pp ln a l* pp f ls ->
!- h i t l .h i e <tr e >
/a gt
< ag tn m=j ln "
t r e ae"s it >
DOWNSITDES

Learning curve if you're not familiar with Ant.
Asynchronous operation, so large builds/deploys may be
slow.
Not everything is available on all OSs.
CONCLUSION
1. Use Phing
2. ???
3. Profit!
CONCLUSION

Phing is a great way to automate repetitive tasks.
Phing can be as simple or complex (and powerful) as you
make it.
Phing can save time and reduce human error.
More Info:
phing.info
Jenkins integration
Jetbrains PhpStorm integration
Eclipse integration
Thanks - Nic Jansma - nicj.net - @NicJ

More Related Content

PPTX
Representing Material Culture Online: Historic Clothing in Omeka
PDF
Social Network Analysis With R
PDF
Introduction to Ansible
PDF
PDF
Geb for Testing Your Grails Application GR8Conf India 2016
PDF
WordPress in 30 minutes
PPT
wreewrer
PDF
密瑪學原理與技術
Representing Material Culture Online: Historic Clothing in Omeka
Social Network Analysis With R
Introduction to Ansible
Geb for Testing Your Grails Application GR8Conf India 2016
WordPress in 30 minutes
wreewrer
密瑪學原理與技術

What's hot (18)

PDF
網路攻擊技術分析
PDF
Refactoring to symfony components
PDF
Profiling Web Archives IIPC GA 2015
PDF
Top 10 php classic traps DPC 2020
PDF
TypeScriptで書くAngularJS @ GDG神戸2014.8.23
PDF
Web應用程式以及資安問題的探討
PDF
モダンAngularJS @ GDG中国2014.12.6
PDF
PHP an intro -1
PDF
Web Sémantique ou comment les ontologies pourront favoriser l\'échange des co...
PDF
Fast api
TXT
Send.php
PDF
Linux Commands
TXT
https://www.facebook.com/valdyna.monna?fref=ts
PPTX
Perl в хэке и хэки в Perl
PDF
Speeding up Red Team engagements with carnivorall
PDF
Tong Hop Bai Tap C
TXT
Show messagehello
網路攻擊技術分析
Refactoring to symfony components
Profiling Web Archives IIPC GA 2015
Top 10 php classic traps DPC 2020
TypeScriptで書くAngularJS @ GDG神戸2014.8.23
Web應用程式以及資安問題的探討
モダンAngularJS @ GDG中国2014.12.6
PHP an intro -1
Web Sémantique ou comment les ontologies pourront favoriser l\'échange des co...
Fast api
Send.php
Linux Commands
https://www.facebook.com/valdyna.monna?fref=ts
Perl в хэке и хэки в Perl
Speeding up Red Team engagements with carnivorall
Tong Hop Bai Tap C
Show messagehello
Ad

Viewers also liked (11)

PPTX
Using Modern Browser APIs to Improve the Performance of Your Web Applications
PDF
The Happy Path: Migration Strategies for Node.js
PDF
Measuring Continuity
PPTX
Appcelerator Titanium Intro
PDF
Appcelerator Titanium Intro (2014)
PDF
Sails.js Intro
PDF
Forensic Tools for In-Depth Performance Investigations
PPTX
Html5 devconf nodejs_devops_shubhra
PDF
Measuring the Performance of Single Page Applications
PDF
Javascript Module Patterns
PDF
Measuring Real User Performance in the Browser
Using Modern Browser APIs to Improve the Performance of Your Web Applications
The Happy Path: Migration Strategies for Node.js
Measuring Continuity
Appcelerator Titanium Intro
Appcelerator Titanium Intro (2014)
Sails.js Intro
Forensic Tools for In-Depth Performance Investigations
Html5 devconf nodejs_devops_shubhra
Measuring the Performance of Single Page Applications
Javascript Module Patterns
Measuring Real User Performance in the Browser
Ad

Similar to Using Phing for Fun and Profit (20)

PDF
PyLadies Talk: Learn to love the command line!
PDF
Continuous delivery with Gradle
PDF
JavaFX, because you're worth it
PDF
Testing Fuse Fabric with Pax Exam
PDF
An Introduction to CSS Preprocessors
PDF
Spring Roo 2.0 Preview at Spring I/O 2016
PDF
Flow of events during Media Player creation in Android
PDF
톰캣 #05+a-배치-parallel deployment
PDF
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
PPTX
From simple to more advanced: Lessons learned in 13 months with Tableau
PDF
Noah Zoschke at Waza 2013: Heroku Secrets
PDF
Nginx Scripting - Extending Nginx Functionalities with Lua
PDF
Devinsampa nginx-scripting
PDF
Spring scala - Sneaking Scala into your corporation
PDF
Testing TYPO3 Applications
PDF
Marko Gargenta_Remixing android
PDF
Create Custom Post Type Plugin
PDF
Theme Development and Customization
PDF
Kernel Recipes 2015: Introduction to Kernel Power Management
PDF
rpm-building-101.pdf
PyLadies Talk: Learn to love the command line!
Continuous delivery with Gradle
JavaFX, because you're worth it
Testing Fuse Fabric with Pax Exam
An Introduction to CSS Preprocessors
Spring Roo 2.0 Preview at Spring I/O 2016
Flow of events during Media Player creation in Android
톰캣 #05+a-배치-parallel deployment
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
From simple to more advanced: Lessons learned in 13 months with Tableau
Noah Zoschke at Waza 2013: Heroku Secrets
Nginx Scripting - Extending Nginx Functionalities with Lua
Devinsampa nginx-scripting
Spring scala - Sneaking Scala into your corporation
Testing TYPO3 Applications
Marko Gargenta_Remixing android
Create Custom Post Type Plugin
Theme Development and Customization
Kernel Recipes 2015: Introduction to Kernel Power Management
rpm-building-101.pdf

More from Nicholas Jansma (6)

PPTX
Modern Metrics (2022)
PPTX
Check Yourself Before You Wreck Yourself: Auditing and Improving the Performa...
PDF
When Third Parties Stop Being Polite... and Start Getting Real
PDF
Reliably Measuring Responsiveness
PDF
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...
PPTX
Debugging IE Performance Issues with xperf, ETW and NavigationTiming
Modern Metrics (2022)
Check Yourself Before You Wreck Yourself: Auditing and Improving the Performa...
When Third Parties Stop Being Polite... and Start Getting Real
Reliably Measuring Responsiveness
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...
Debugging IE Performance Issues with xperf, ETW and NavigationTiming

Recently uploaded (20)

PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
Big Data Technologies - Introduction.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation theory and applications.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Machine Learning_overview_presentation.pptx
PDF
Getting Started with Data Integration: FME Form 101
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Big Data Technologies - Introduction.pptx
MIND Revenue Release Quarter 2 2025 Press Release
A comparative analysis of optical character recognition models for extracting...
MYSQL Presentation for SQL database connectivity
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation theory and applications.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
A Presentation on Artificial Intelligence
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
Machine Learning_overview_presentation.pptx
Getting Started with Data Integration: FME Form 101
Digital-Transformation-Roadmap-for-Companies.pptx
Programs and apps: productivity, graphics, security and other tools
Reach Out and Touch Someone: Haptics and Empathic Computing
SOPHOS-XG Firewall Administrator PPT.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11

Using Phing for Fun and Profit

  • 1. USING PHING FOR FUN AND PROFIT PHING: A PHP BUILD SYSTEM Nic Jansma nicj.net @NicJ
  • 2. PHING Phing is a cross-platform PHP build tool, similar to Apache Ant.
  • 3. WHAT IS A BUILD TOOL? A build tool helps you automate repetitive tasks.
  • 4. A BUILD TOOL HELPS YOU... Build resources (CSS, JavaScript, templates, etc) Validate code (lint, sniff, etc) Run unit tests Build documentation Create packages Deploy code Execute system commands ... and anything else you do repetitively ...
  • 5. WHY USE A BUILD TOOL? Otherwise you will f*** up. You should automate everything you can. Automating your processes will save you time. Automating your processes will save you from your future self. Maybe not today, maybe not tomorrow, but at some point you will make a mistake if it's not automated.
  • 6. WHY USE PHING? It's written in PHP, so if the rest of your project is PHP, you can run Phing. Besides PHP, no other external dependencies are needed (such as Ruby or Java). Great community support, with hundreds of different tasks.
  • 7. INSTALLATION - GITHUB github.com/phingofficial/phing $ gt c oe ht s / gt u .o /h no fc a /h n. i > i l n tp : /i hb cm p ig fi il pi g gt $ pp p ig bn pi g > h h n i h n
  • 8. INSTALLATION - PHAR PACKAGE www.phing.info/trac/wiki/Users/Download $ w e h t : / w . h n . n o g t p i g l t s . h r - p i gp a > g t tp /w wp ig i f / e/ hn -a e tp a O hn .h r $ pp p ig pa > h h n. hr
  • 9. INSTALLATION - PEAR $ pa c an ld s oe p a. hn .n o > e r hn e- ic vr e rp i gi f $ pa i sa lp i gp ig > e r nt l hn /h n $ pi g > hn
  • 10. INSTALLATION COMPOSER composer.json: { " eu r" { r q ie : "hn /h n " " . ." pi gp ig : 26 1 } } $ pp c mo e. hr is a l > h o ps rp a n tl L ai gc mo e rp st r e w t pc ae i fr ai n o dn op sr e oi oi s ih a kg n om t o I sa ln d pn ec e (n ld n rq ie d v n tl i g e ed n is i cu ig e ur -e ) -I sa ln p ig pi g (. .) n t li g h n/h n 26 1 D wl ai g 10 o n od n: 0 % W ii gl c fl r tn ok ie G nr tn a tl a fl s e ea i g u oo d ie $ pp v no h n hn i hn > h e dr pi g pi g b np i g
  • 11. PHING OVERVIEW Phing is driven by XML files that define your projects, build targets, and individual tasks. The XML format is very similar to Apache Ant.
  • 12. PHING - PROJECTS A project is the root element of your XML. The < r j c >defines of all of your build targets and the poet tasks that will execute for the targets. Only the d f u tattribut is required, which specifies the eal default target to run. < xl vr in ". " ec dn =U F 8? ? m e so =1 0 no i g" T- "> < rj c nm =m -r jc " df ut "u l" p oe t ae "y p oe t ea l =b id > < - tr es ad ts s -> ! - ag t n a k < - .. -> !- . <po et /rj c >
  • 13. PHING - TARGETS A < a g t is a logical set of actions you want to take. tre> A < a g t can have tasks. tre> A < a g t can also have a list of other targets it depends tre> on. < xl vr in ". " ec dn =U F 8? ? m e so =1 0 no i g" T- "> < rj c nm =m -r jc " df ut "u l" p oe t ae "y p oe t ea l =b id > < ag tn m=b id d pn s" la ,i t mn f"/ t r e ae"u l" e ed = ce nl n, ii y > < ag tn m=c en > t r e ae"l a" <co mg " ' c e nn y u b id / eh s =I m la ig o r ul " > <tr e > /a gt < - .. -> !- . <po et /rj c >
  • 14. PHING - TASKS A task will take an action. Tasks can be a core task that Phing ships with, or an external plug-in that you write. < xl vr in ". " ec dn =U F 8? ? m e so =1 0 no i g" T- "> < rj c nm =m -r jc " df ut "u l" p oe t ae "y p oe t ea l =b id > < ag tn m=c en > t r e ae"l a" <co mg " ' c e nn y u b id / eh s =I m la ig o r ul " > <ee e d r"u l" / dl t i=bi d > <tr e > /a gt <po et /rj c >
  • 15. PHING - CORE TASKS 123 built-in tasks. Some of the most useful: File operations: a p n , c p , d l t , m d r ped oy eee ki Conditional logic: c n i i n f r a h i , f i odto, oec, f al Input / output: e h , i p t co nu System: e e , t t m , t s d f xc sap ake Source control: g t , s n , c s i* v* v* Network: f p e l y h t g t m i , s p t s p s h tdpo, tpe, al 3u, c, s External Libraries: p p o e n f e , p p n t hcdsifr hui, p p o u e t rj l n , p p d hdcmno, sit hm
  • 16. PHING - PROPERTIES A property is a variable. Properties can come from built-in properties (Phing environment variables), a b i d p o e t e file, or ul.rpris created at runtime in your XML file via the < r p r y poet> element. Use properties via the $ p o e t n m }syntax. {rpryae < xl vr in ". " ec dn =U F 8? ? m e so =1 0 no i g" T- "> < rj c nm =m -r jc " df ut "l a" p oe t ae "y p oe t ea l =c en > < rp ry nm = bi di "v l e" /u l" / p o et a e" ul d r au=. bi d > < ag tn m=c en > t r e ae"l a" <co mg " ' c e nn $ bi di } / eh s =I m la ig { ul dr " > <ee e d r"{ ul dr " / dl t i=$b i di } > <tr e > /a gt <po et /rj c >
  • 17. PHING - BUILT-IN PROPERTIES There are many built-in properties: apiainsati,ev* hs.rh plcto.trdr n., otac, hs.oan hs.sye hs.ae hs.s otdmi, otftp, otnm, oto, hs.srlae hs.svrin oto.ees, oto.eso, ln.eaao,o.ae pigfl, iesprtr snm, hn.ie pigdr pighm,pigvrin hn.i, hn.oe hn.eso, pigpoetnm,ppcasah hn.rjc.ae h.lspt, ppvrin poetbsdr ue.oe h.eso, rjc.aei, srhm
  • 18. PHING - .PROPERTIES FILES Simple k y v l eformat e=au #Ti i ac me t i t e .r pr is fl hs s om n n h po e te i e k yv le e =a u b id i= ul u ld r bi d m ap nm =o y p. a ef o m ap ul ht :/ o .o y p. r =t p/ fo cm < xl vr in ". " ec dn =U F 8? ? m e so =1 0 no i g" T- "> < rj c nm =m -r jc " df ut "l a" p o e t a e " y p o e t e a l =c e n > < rp ry fl = .b id po e te "/ p o et i e" /u l .r pr is > < ag tn m= c en > t r e ae "l a" < co mg " ' c e nn $ bi di }f r$ m ap nm } / eh s =I m la ig { ul dr o {y p. a e" > <ee e d r"{ ul dr " / dl t i= $b i di } > < tr e> / a gt < po et / rj c>
  • 19. PHING - < R P R Y POET> Define new properties in your XML. < xl vr in ". " ec dn =U F 8? ? m e so =1 0 no i g" T- "> < rj c nm =m -r jc " df ut "u l" p o e t a e " y p o e t e a l =b i d > < rp ry nm = bi di "v l e" /u l" / p o et a e" ul d r au =. bi d > < rp ry nm = cs i"vl e "{ ul }c s / p o et a e" sd r a u= $b id / s" > < rp ry nm = jd r vl e"{u l} j "/ p o et a e" si " au =$b id /s > < ag tn m= c en > t r e ae "l a" <ee e d r"{ sd r"/ dl t i= $c s i} > <ee e d r"{ si } / dl t i= $j d r" > < tr e> / a gt < po et / rj c>
  • 21. SIMPLE < xl vr in ". " ec dn =U F 8? ? m e so =1 0 no i g" T- "> < rj c nm =m -r jc " df ut "c o > p oe t ae "y p oe t ea l =e h" < ag tn m=e h" t r e ae"c o > <co mg " el "/ eh s =H lo > <tr e > /a gt <po et /rj c > > pi geh $ h n co B id ie . bi dx l u lf l : ul . m m -r jc > eh : y po e t co [ c o H lo eh ] el B ID FN SE U L I IH D T tl tm :0 18 s cn s o a i e .7 0 eo d
  • 22. TWO TASKS < xl vr in ". " ec dn =U F 8? ? m e so =1 0 no i g" T- "> < rj c nm =m -r jc " df ut "i s" p oe t ae "y p oe t ea l =f rt > < ag tn m=f rt d pn s" eo d / t r e ae"i s" e ed = sc n" > < ag tn m=s cn " t r e ae"e od > <al ms a e" o ms e u" / fi e sg =Y u es d p > <tr e > /a gt <po et /rj c > > pi g fr t $ h n is B id ie . bi dx l u lf l: ul . m m -r jc > sc n : y po e t eo d E eu in o tr e "e od f ie f rt ef lo i gr ao : x ct o f ag t sc n " a l d o h ol wn e s n . bi dx l1: 2 Y u ms e u u l. m: 62 : o es d p B ID FI E U L A LD . bi dx l1:2 Y um s e u ul . m: 62 : o es d p T tl tm :0 10 s cn s o a i e .8 0 eo d
  • 23. SHELL COMMANDS < xl vr in ". " ec dn =U F 8? ? m e so =1 0 no i g" T- "> < rj c nm =m -r jc " df ut "e ly > p oe t ae "y p oe t ea l =d po " < rp rynm = dp o. ot a e v le " o. o"/ p o et a e" el y hs nm " au=f oc m > < ag tn m=d po " t r e ae"e ly > <xc ee c ma d"s n -v . $d po . ot ae / om n=ry z az / { el yh sn m }" d r" { rj c. ae i } i= $p oe t bs dr " c ek e un"r e / hc rt r=t u" > <tr e > /a gt <po et /rj c >
  • 24. EXTERNAL PHP < xl vr in ". " ec dn =U F 8? ? m e so =1 0 no i g" T- "> < rj c nm =m -r jc " df ut "x en l ak > p oe t ae "y p oe t ea l =e tr at s" < ag tn m=e tr at s" t r e ae"x en l ak > <ak e ts df n m=m po et ak ae"y rj c ts " c as a h" {r jc . ae i} ls pt=$ p oe tb sd r" c as a e" ya k / <- .M T s. h -> ls nm=M T s" > !- / ya kp p <yr jc t s m s ae'i / mp oe ta k es g=h ' > <tr e > /a gt <po et /rj c > < pp ?h r qi eo c 'h n/ ak p p; e ur _ ne pi g Ts .h ' c as MT s et ns Ts { l s y ak xe d a k p oe td $e s g; r t ce m sa e / s tf o t e ts ' at iu ei t eX L / e r m h ak s tr b t n h M p bi f nt o st es g (m sa e { u l c u ci n eM s ae $e sg ) $ hs>e s g = $ es g; ti-m sa e m sa e } / e eu e w e ts i c le / x ct d hn a k s a l d p bi f nt o mi ( { u l c u ci n an ) e h $h s> es g ; co ti - ms ae }
  • 25. EXTERNAL PHP - OUTPUT $ pi ge tr at s > hn xe nl ak B id ie . bi d x l u lf l : ul . m [ rp r y L ai g .b id po e te po et ] od n u l .r pr is m -r jc > et ra ts : y po e t xe n la k h i B ID FN SE U L I IH D T tl tm :0 23 s cn s o a i e .9 0 eo d
  • 26. CONTINUOUS INTEGRATION / BUILD SERVER < xl vr in ". " ec dn =U F 8? ? m e so =1 0 no i g" T- "> < rj c nm =b gp oe t df u t" ul " p oe t ae "i - rj c" e al =b id > < - mi tr e s- > ! - an a gt < ag tn m=b id d pn s" la ,h c ot ln , t r e ae"u l" e ed = ce nc ek u, i t s if pp d ts ,o ,a k g" / nf ,h m, et d cp ca e > < ag tn m=d po "d pn s"u l, r- el y ry cr la e / t r e ae"e ly ee d=bi dp e dp o, sn , ee s" > < ag tn m=c en > t r e ae"l a" < - ce nt eb i d- > !- la h ul <tr e > /a gt < ag tn m=c ek u" t r e ae"h co t > < - ce ku / pl l ts f o s u c c n rl -> !- hc o t u l a e t r m or e ot o <tr e > /a gt < ag tn m=l n" dp ns " hl n, si tc s it / t r e ae"i t e ed =p pi tj l n, sl n" > < ag tn m=p pi t> t r e ae"h ln " < - pp ln a l* pp f ls -> !- h i t l .h i e <tr e > /a gt < ag tn m=j ln " t r e ae"s it >
  • 27. DOWNSITDES Learning curve if you're not familiar with Ant. Asynchronous operation, so large builds/deploys may be slow. Not everything is available on all OSs.
  • 28. CONCLUSION 1. Use Phing 2. ??? 3. Profit!
  • 29. CONCLUSION Phing is a great way to automate repetitive tasks. Phing can be as simple or complex (and powerful) as you make it. Phing can save time and reduce human error. More Info: phing.info Jenkins integration Jetbrains PhpStorm integration Eclipse integration Thanks - Nic Jansma - nicj.net - @NicJ