SlideShare a Scribd company logo
Automation Using
                            Phing
                        rajat_pandit@ipcmedia.com




Sunday, 20 June 2010
What is phing
                 • Phing Is Not Gnumake
                 • Its a project build tool
                 • Based on Apache Ant
                 • Cross Platform (Runs everywhere php
                       works)
                 • Lots of projects using it (Propel, Xinc,
                       symfony, prada)

Sunday, 20 June 2010
No compiling involved,
                       so what does it build?
                 • Automation of non-development tasks
                       • Configuring
                       • Packaging
                       • Uploading to remote servers
                       • Testing


Sunday, 20 June 2010
More automation...
                 • Run unit tests for you and publish
                       reports

                 • Build API Docs
                 • Package and / or install PEAR
                       packages
                 • Environment Setup
                 • App Configuration

Sunday, 20 June 2010
More automation...

                 • setting up permissions
                 • environment setup
                 • app config
                 • basically anywhere you can script,
                       you can use phing



Sunday, 20 June 2010
Other Alternatives
                             available
                 • Quite a few options available:
                       • ANT, Rake, NAnt
                 • Why Phing then?
                       • Dev already familiar with the language
                       • You can embed php straight in your build
                         script

                       • Custom extensions are easy to write
                       • Works across platforms, small footprint

Sunday, 20 June 2010
Phing: Basics

                 • Task: Built in custom piece of code to
                       perform a specific function

                 • Target: Grouping of tasks to perform
                       a more general function

                 • Project: Root node of build files
                       containing one or more targets



Sunday, 20 June 2010
Phing: Sample Build File
                 <project name="trustedreviews" default="main">
                   <property name="ver" value="1.0.1"
                   <property file="build.properties" />
                   <target name="main">
                     <mkdir dir="./build/${ver}">
                     <copy todir="./build/${veer}">
                       <fileset dir="." includes="*.txt" />
                     </copy>
                   </target>
                 </project>




Sunday, 20 June 2010
Phing: Selecting a bunch
                        of files
                 • <fileset> is used to represent a
                       bunch of files to do stuff with

                 • Many tasks support <fileset>
                       <fileset dir="/foo"
                       	 includes="**/*.html"
                       	 excludes="**/test-*" />

                       <fileset dir="/bla">
                       	 <includes name="img/${theme}/*.jpg" />
                       	 <includes name="js/*.js" />
                 •     </fileset>



Sunday, 20 June 2010
Phing: Fine tuning the
                              selection
                 • You might need to fine tune your file
                       selection further:
                       • Filter on date range?
                       • Filter on file size
                       • Type (File or Directory)
                       • At a particular depth

Sunday, 20 June 2010
Phing: Fine tuning the
                              selection
             <fileset dir="${htdocs.dir}">
             	 <includes name="**/*.html" />
             	 <containsregexp expression="/prodd+.php" />
             </fileset>

             <fileset dir="${dist}" includes="**">
             	 <or>
             	 	 <present targetdir="${htdocs}" />
             	 	 <date datetime="01/01/2010" when="before" />
             	 </or>
             </fileset>




Sunday, 20 June 2010
Phing: Filesystem
                           Transformation

                 • <mapper> element adds filesystem
                       transformation capabilities for tasks
                       that support it e.g. <copy>, <move> etc
                       <copy todir="/tmp">
                       	 <mapper type="glob" from="*.php" to="*.php.bak" />
                       	 <fileset dir="./app" includes="**/*.php" />
                 •     </copy>




Sunday, 20 June 2010
Phing: Filesystem
                          Transformation
                 • Other kind of mappers present:
                       • Flatten Mapper: Gets base filename
                       • Regex Mapper: Changes filenames
                         based on regular expressions
                       • Merge Mapper: change all source
                         filenames to the same name


Sunday, 20 June 2010
Phing: Data
                            Transformation
                 • <filterchain> is used to transform the
                       contents of the file. Supported by many tasks
                       like <copy>, <move> etc

                 • Can perform various actions:
                       • Strip comments from your files
                       • Replace values in your file
                       • Perform XSLT Transformations
                       • Above all your chain these transformations

Sunday, 20 June 2010
Phing: Data
                             Transformation
                       <copy todir="${build}/htdocs">
                       	 <fileset includes="*.html" />
                       	 <filterchain>
                       	 	 <replaceregexp>
                       	 	 	 <regexp pattern="rn" replace="n" />
                       	 	 </replaceregexp>
                       	 	 <tidyfilter encoding="utf8">
                       	 	 	 <config name="indent" value="true" />
                       	 	 </tidyfilter>
                       	 </filterchain>
                       </copy>




Sunday, 20 June 2010
Phing: Data
                            Transformation
                 • <headfilter> Reads only the first n lines of the file
                 • <linecontains> Filters out lines that contain a
                       specific word
                 • <linecontainsregexp> Filters out lines that
                       contain a specific regular expression

                 • <prefixlines> Adds stuff to the lines of the
                       selected files
                 • <tabtospaces> Converts tabs to spaces
                       (HURRAH!!)


Sunday, 20 June 2010
Phing: More Data
                          Transformations

                 • <StripPHPComments> Takes out php
                       comments
                 • <replaceregexp>
                 • <replacetokens> This can particularly
                       be handy for spec files



Sunday, 20 June 2010
Phing: Data
                           Transformations
                 • Consider a file that contains:
                       The current user is ##current_user##
                 • Use this build target to replace the
                       token
                       <property environment="env" />
                       <filterchain>
                       	 <replacetokens begintoken="##" endtoken="##">
                       	 	 <token key="CURRENT" value="${env.LOGNAME}" />
                       	 <replacetoken>
                       </filterchain>




Sunday, 20 June 2010
Phing: Packaging


                 • Tasks like <tar> <zip> can compress
                       and package the set of files you want
                       to compress

                 • <pearpkg> and <pearpkg2> allows you
                       to build pear package using phing




Sunday, 20 June 2010
Phing: Version Control
                          and Deployment
                 • <svn*> tasks provide support for subversion:
                       • <svncheckout>
                       • <svncommit>
                       • <svnexport>
                       • <svnlastrevision>
                 • <scp> to move files to another server
                 • Support for CSV also present

Sunday, 20 June 2010
Phing: Support for DB
                            Migration
                 • <pdosqlexec> and <creole> provides
                       execution of database statements
                 • <dbdeploy> can take care of db
                       migrations
                       http://dbdeploy.com/documentation/getting-started/rules-for-
                       using-dbdeploy/


                 • Drupal Deployment solution anyone?


Sunday, 20 June 2010
Phing: Validating Code

                 • <jslint> using an external utility jsl
                 • <xmllint> uses internal DOM support
                       for validating against given schema
                       file

                 • <phplint> just uses php -l
                 • <tidy> can be use to validate markup
                       and cleanup html


Sunday, 20 June 2010
Phing: Php API Docs

                 • Support for phpDocumentor
                       <phpdoc title="API Documentation"
                         destdir="apidocs" sourcecode="no"
                         output="HTML:Smarty:PHP">
                         <fileset dir="./classes">
                            <include name="**/*.php" />
                         </fileset>
                       </phpdoc>




Sunday, 20 June 2010
Phing: Extending
                            Functionalities
                 • Two ways to extend Phing:
                       • Embed PHP in the build file itself (not the cleanest
                          solution)

                       • Write your own class to provide any of the following
                          functioanlity:
                         • Task
                         • Type
                         • Selector
                         • Filter
                         • and more...


Sunday, 20 June 2010
Phing: Extending
                            Functionality
                 • <phpevaltask> lets you set a property
                       to the results of evaluating a PHP
                       Expression or the results by a
                       function call.
                       <php function="crypt" returnProperty="enc_passwd">
                         <param value="${auth.root_passwd}"/>
                       </php>

                       <php expression="3 + 4" returnProperty="sum"/>
                       <php expression="echo 'test';">




Sunday, 20 June 2010
Phing: Extending
                           Functionality


                 • <adhoc-task> allows you to define a
                       task within your build file.




Sunday, 20 June 2010
Phing: Extending
                           Functionality
                  <target name="main"
                          description="==>test AdhocTask ">
                  	 	
                  	 	 <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="B.L.I.N.G"/>
                  </target>




Sunday, 20 June 2010
Phing: Scripting & Logic
                 • Phing also supports conditional tags
                       <if>
                        <equals arg1="${foo}" arg2="bar" />
                        <then>
                          <echo message="The value of property foo is
                       'bar'" />
                        </then>
                        </elseif>
                        <else>
                          <echo message="The value of property foo is not
                       'foo' or 'bar'" />
                        </else>
                       </if>




Sunday, 20 June 2010
Phing: Writing a custom
                    task
                require_once "phing/Task.php";
                class MyEchoTask extends Task {
                     /**
                       * The message passed in the buildfile.
                       */
                     private $message = null;
                     /**
                       * The setter for the attribute "message"
                       */
                     public function setMessage($str) {
                          $this->message = $str;
                     }
                     /**
                       * The init method: Do init steps.
                       */
                     public function init() {
                        // nothing to do here
                     }
                     /**
                       * The main entry point method.
                       */
                     public function main() {
                        print($this->message);
Sunday, 20 June 2010 }
Phing: Using the
                         <myecho> task
             <?xml version="1.0" ?>
             <project name="test" basedir="." default="myecho">
                 <taskdef name="myecho"
             classname="phing.tasks.my.MyEcho" />

                 <target name="test.myecho">
                   <myecho message="Hello World" />
                 </target>
             </project>




Sunday, 20 June 2010
What Next?
                  F    P       C   I
                               P




Sunday, 20 June 2010
Questions?




Sunday, 20 June 2010
Ad

More Related Content

What's hot (9)

Modern iframe programming
Modern iframe programmingModern iframe programming
Modern iframe programming
benvinegar
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015
Chris McEniry
 
How to start developing your own ExpressionEngine addons
How to start developing your own ExpressionEngine addonsHow to start developing your own ExpressionEngine addons
How to start developing your own ExpressionEngine addons
Leevi Graham
 
Epub ppt
Epub pptEpub ppt
Epub ppt
Sudhakar Maneindal
 
Automation with phing
Automation with phingAutomation with phing
Automation with phing
Joey Rivera
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino API
Paul Withers
 
Web micro-framework BATTLE!
Web micro-framework BATTLE!Web micro-framework BATTLE!
Web micro-framework BATTLE!
Richard Jones
 
Let's create a multilingual site in WordPress
Let's create a multilingual site in WordPressLet's create a multilingual site in WordPress
Let's create a multilingual site in WordPress
Marko Heijnen
 
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi   SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
Sencha
 
Modern iframe programming
Modern iframe programmingModern iframe programming
Modern iframe programming
benvinegar
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015
Chris McEniry
 
How to start developing your own ExpressionEngine addons
How to start developing your own ExpressionEngine addonsHow to start developing your own ExpressionEngine addons
How to start developing your own ExpressionEngine addons
Leevi Graham
 
Automation with phing
Automation with phingAutomation with phing
Automation with phing
Joey Rivera
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino API
Paul Withers
 
Web micro-framework BATTLE!
Web micro-framework BATTLE!Web micro-framework BATTLE!
Web micro-framework BATTLE!
Richard Jones
 
Let's create a multilingual site in WordPress
Let's create a multilingual site in WordPressLet's create a multilingual site in WordPress
Let's create a multilingual site in WordPress
Marko Heijnen
 
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi   SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
SenchaCon 2016: The Modern Toolchain - Ross Gerbasi
Sencha
 

Viewers also liked (20)

I.T.A.K.E Unconference - Mutation testing to the rescue of your tests
I.T.A.K.E Unconference - Mutation testing to the rescue of your testsI.T.A.K.E Unconference - Mutation testing to the rescue of your tests
I.T.A.K.E Unconference - Mutation testing to the rescue of your tests
Nicolas Fränkel
 
Get Soaked - An In Depth Look At PHP Streams
Get Soaked - An In Depth Look At PHP StreamsGet Soaked - An In Depth Look At PHP Streams
Get Soaked - An In Depth Look At PHP Streams
Davey Shafik
 
Elastic Searching With PHP
Elastic Searching With PHPElastic Searching With PHP
Elastic Searching With PHP
Lea Hänsenberger
 
Techniques d'accélération des pages web
Techniques d'accélération des pages webTechniques d'accélération des pages web
Techniques d'accélération des pages web
Jean-Pierre Vincent
 
Diving deep into twig
Diving deep into twigDiving deep into twig
Diving deep into twig
Matthias Noback
 
PHP5.5 is Here
PHP5.5 is HerePHP5.5 is Here
PHP5.5 is Here
julien pauli
 
Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP Generators
Mark Baker
 
The quest for global design principles (SymfonyLive Berlin 2015)
The quest for global design principles (SymfonyLive Berlin 2015)The quest for global design principles (SymfonyLive Berlin 2015)
The quest for global design principles (SymfonyLive Berlin 2015)
Matthias Noback
 
Top tips my_sql_performance
Top tips my_sql_performanceTop tips my_sql_performance
Top tips my_sql_performance
afup Paris
 
Mocking Demystified
Mocking DemystifiedMocking Demystified
Mocking Demystified
Marcello Duarte
 
Understanding Craftsmanship SwanseaCon2015
Understanding Craftsmanship SwanseaCon2015Understanding Craftsmanship SwanseaCon2015
Understanding Craftsmanship SwanseaCon2015
Marcello Duarte
 
Why elasticsearch rocks!
Why elasticsearch rocks!Why elasticsearch rocks!
Why elasticsearch rocks!
tlrx
 
Writing infinite scalability web applications with PHP and PostgreSQL
Writing infinite scalability web applications with PHP and PostgreSQLWriting infinite scalability web applications with PHP and PostgreSQL
Writing infinite scalability web applications with PHP and PostgreSQL
Gabriele Bartolini
 
Si le tdd est mort alors pratiquons une autopsie mix-it 2015
Si le tdd est mort alors pratiquons une autopsie mix-it 2015Si le tdd est mort alors pratiquons une autopsie mix-it 2015
Si le tdd est mort alors pratiquons une autopsie mix-it 2015
Bruno Boucard
 
L'ABC du BDD (Behavior Driven Development)
L'ABC du BDD (Behavior Driven Development)L'ABC du BDD (Behavior Driven Development)
L'ABC du BDD (Behavior Driven Development)
Arnauld Loyer
 
Performance serveur et apache
Performance serveur et apachePerformance serveur et apache
Performance serveur et apache
afup Paris
 
Caching on the Edge
Caching on the EdgeCaching on the Edge
Caching on the Edge
Fabien Potencier
 
Behat 3.0 meetup (March)
Behat 3.0 meetup (March)Behat 3.0 meetup (March)
Behat 3.0 meetup (March)
Konstantin Kudryashov
 
TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016
CiaranMcNulty
 
The Wonderful World of Symfony Components
The Wonderful World of Symfony ComponentsThe Wonderful World of Symfony Components
The Wonderful World of Symfony Components
Ryan Weaver
 
I.T.A.K.E Unconference - Mutation testing to the rescue of your tests
I.T.A.K.E Unconference - Mutation testing to the rescue of your testsI.T.A.K.E Unconference - Mutation testing to the rescue of your tests
I.T.A.K.E Unconference - Mutation testing to the rescue of your tests
Nicolas Fränkel
 
Get Soaked - An In Depth Look At PHP Streams
Get Soaked - An In Depth Look At PHP StreamsGet Soaked - An In Depth Look At PHP Streams
Get Soaked - An In Depth Look At PHP Streams
Davey Shafik
 
Techniques d'accélération des pages web
Techniques d'accélération des pages webTechniques d'accélération des pages web
Techniques d'accélération des pages web
Jean-Pierre Vincent
 
Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP Generators
Mark Baker
 
The quest for global design principles (SymfonyLive Berlin 2015)
The quest for global design principles (SymfonyLive Berlin 2015)The quest for global design principles (SymfonyLive Berlin 2015)
The quest for global design principles (SymfonyLive Berlin 2015)
Matthias Noback
 
Top tips my_sql_performance
Top tips my_sql_performanceTop tips my_sql_performance
Top tips my_sql_performance
afup Paris
 
Understanding Craftsmanship SwanseaCon2015
Understanding Craftsmanship SwanseaCon2015Understanding Craftsmanship SwanseaCon2015
Understanding Craftsmanship SwanseaCon2015
Marcello Duarte
 
Why elasticsearch rocks!
Why elasticsearch rocks!Why elasticsearch rocks!
Why elasticsearch rocks!
tlrx
 
Writing infinite scalability web applications with PHP and PostgreSQL
Writing infinite scalability web applications with PHP and PostgreSQLWriting infinite scalability web applications with PHP and PostgreSQL
Writing infinite scalability web applications with PHP and PostgreSQL
Gabriele Bartolini
 
Si le tdd est mort alors pratiquons une autopsie mix-it 2015
Si le tdd est mort alors pratiquons une autopsie mix-it 2015Si le tdd est mort alors pratiquons une autopsie mix-it 2015
Si le tdd est mort alors pratiquons une autopsie mix-it 2015
Bruno Boucard
 
L'ABC du BDD (Behavior Driven Development)
L'ABC du BDD (Behavior Driven Development)L'ABC du BDD (Behavior Driven Development)
L'ABC du BDD (Behavior Driven Development)
Arnauld Loyer
 
Performance serveur et apache
Performance serveur et apachePerformance serveur et apache
Performance serveur et apache
afup Paris
 
TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016
CiaranMcNulty
 
The Wonderful World of Symfony Components
The Wonderful World of Symfony ComponentsThe Wonderful World of Symfony Components
The Wonderful World of Symfony Components
Ryan Weaver
 
Ad

Similar to Automation using-phing (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
Michiel Rook
 
Putting "Phings" together - how to automate your life
Putting "Phings" together - how to automate your lifePutting "Phings" together - how to automate your life
Putting "Phings" together - how to automate your life
Boyan Borisov
 
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
Michiel Rook
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
Pavan Kumar N
 
Large Files without the Trials
Large Files without the TrialsLarge Files without the Trials
Large Files without the Trials
Jazkarta, Inc.
 
Bar Camp Auckland - Mongo DB Presentation BCA4
Bar Camp Auckland - Mongo DB Presentation BCA4Bar Camp Auckland - Mongo DB Presentation BCA4
Bar Camp Auckland - Mongo DB Presentation BCA4
John Ballinger
 
"How Mozilla Uses Selenium"
"How Mozilla Uses Selenium""How Mozilla Uses Selenium"
"How Mozilla Uses Selenium"
Stephen Donner
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino API
Oliver Busse
 
The Dojo Toolkit An Introduction
The Dojo Toolkit   An IntroductionThe Dojo Toolkit   An Introduction
The Dojo Toolkit An Introduction
Jeff Fox
 
Automating Web Application Deployment
Automating Web Application DeploymentAutomating Web Application Deployment
Automating Web Application Deployment
Mathew Byrne
 
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
John Woodell
 
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
Hiroki Ohtsuka
 
OSMC 2009 | Nagios Plugins: New features and future projects by Thomas Guyot-...
OSMC 2009 | Nagios Plugins: New features and future projects by Thomas Guyot-...OSMC 2009 | Nagios Plugins: New features and future projects by Thomas Guyot-...
OSMC 2009 | Nagios Plugins: New features and future projects by Thomas Guyot-...
NETWAYS
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino API
Oliver Busse
 
Desktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumDesktop Apps with PHP and Titanium
Desktop Apps with PHP and Titanium
Ben Ramsey
 
IS - section 1 - modifiedFinal information system.pptx
IS - section 1 - modifiedFinal information system.pptxIS - section 1 - modifiedFinal information system.pptx
IS - section 1 - modifiedFinal information system.pptx
NaglaaAbdelhady
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011
Bachkoutou Toutou
 
Oscon 2010
Oscon 2010Oscon 2010
Oscon 2010
John Woodell
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Michael Lihs
 
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
Michiel Rook
 
Putting "Phings" together - how to automate your life
Putting "Phings" together - how to automate your lifePutting "Phings" together - how to automate your life
Putting "Phings" together - how to automate your life
Boyan Borisov
 
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
Michiel Rook
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
Pavan Kumar N
 
Large Files without the Trials
Large Files without the TrialsLarge Files without the Trials
Large Files without the Trials
Jazkarta, Inc.
 
Bar Camp Auckland - Mongo DB Presentation BCA4
Bar Camp Auckland - Mongo DB Presentation BCA4Bar Camp Auckland - Mongo DB Presentation BCA4
Bar Camp Auckland - Mongo DB Presentation BCA4
John Ballinger
 
"How Mozilla Uses Selenium"
"How Mozilla Uses Selenium""How Mozilla Uses Selenium"
"How Mozilla Uses Selenium"
Stephen Donner
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino API
Oliver Busse
 
The Dojo Toolkit An Introduction
The Dojo Toolkit   An IntroductionThe Dojo Toolkit   An Introduction
The Dojo Toolkit An Introduction
Jeff Fox
 
Automating Web Application Deployment
Automating Web Application DeploymentAutomating Web Application Deployment
Automating Web Application Deployment
Mathew Byrne
 
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios
 
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
Hiroki Ohtsuka
 
OSMC 2009 | Nagios Plugins: New features and future projects by Thomas Guyot-...
OSMC 2009 | Nagios Plugins: New features and future projects by Thomas Guyot-...OSMC 2009 | Nagios Plugins: New features and future projects by Thomas Guyot-...
OSMC 2009 | Nagios Plugins: New features and future projects by Thomas Guyot-...
NETWAYS
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino API
Oliver Busse
 
Desktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumDesktop Apps with PHP and Titanium
Desktop Apps with PHP and Titanium
Ben Ramsey
 
IS - section 1 - modifiedFinal information system.pptx
IS - section 1 - modifiedFinal information system.pptxIS - section 1 - modifiedFinal information system.pptx
IS - section 1 - modifiedFinal information system.pptx
NaglaaAbdelhady
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011
Bachkoutou Toutou
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Michael Lihs
 
Ad

Recently uploaded (20)

Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 

Automation using-phing

  • 1. Automation Using Phing [email protected] Sunday, 20 June 2010
  • 2. What is phing • Phing Is Not Gnumake • Its a project build tool • Based on Apache Ant • Cross Platform (Runs everywhere php works) • Lots of projects using it (Propel, Xinc, symfony, prada) Sunday, 20 June 2010
  • 3. No compiling involved, so what does it build? • Automation of non-development tasks • Configuring • Packaging • Uploading to remote servers • Testing Sunday, 20 June 2010
  • 4. More automation... • Run unit tests for you and publish reports • Build API Docs • Package and / or install PEAR packages • Environment Setup • App Configuration Sunday, 20 June 2010
  • 5. More automation... • setting up permissions • environment setup • app config • basically anywhere you can script, you can use phing Sunday, 20 June 2010
  • 6. Other Alternatives available • Quite a few options available: • ANT, Rake, NAnt • Why Phing then? • Dev already familiar with the language • You can embed php straight in your build script • Custom extensions are easy to write • Works across platforms, small footprint Sunday, 20 June 2010
  • 7. Phing: Basics • Task: Built in custom piece of code to perform a specific function • Target: Grouping of tasks to perform a more general function • Project: Root node of build files containing one or more targets Sunday, 20 June 2010
  • 8. Phing: Sample Build File <project name="trustedreviews" default="main"> <property name="ver" value="1.0.1" <property file="build.properties" /> <target name="main"> <mkdir dir="./build/${ver}"> <copy todir="./build/${veer}"> <fileset dir="." includes="*.txt" /> </copy> </target> </project> Sunday, 20 June 2010
  • 9. Phing: Selecting a bunch of files • <fileset> is used to represent a bunch of files to do stuff with • Many tasks support <fileset> <fileset dir="/foo" includes="**/*.html" excludes="**/test-*" /> <fileset dir="/bla"> <includes name="img/${theme}/*.jpg" /> <includes name="js/*.js" /> • </fileset> Sunday, 20 June 2010
  • 10. Phing: Fine tuning the selection • You might need to fine tune your file selection further: • Filter on date range? • Filter on file size • Type (File or Directory) • At a particular depth Sunday, 20 June 2010
  • 11. Phing: Fine tuning the selection <fileset dir="${htdocs.dir}"> <includes name="**/*.html" /> <containsregexp expression="/prodd+.php" /> </fileset> <fileset dir="${dist}" includes="**"> <or> <present targetdir="${htdocs}" /> <date datetime="01/01/2010" when="before" /> </or> </fileset> Sunday, 20 June 2010
  • 12. Phing: Filesystem Transformation • <mapper> element adds filesystem transformation capabilities for tasks that support it e.g. <copy>, <move> etc <copy todir="/tmp"> <mapper type="glob" from="*.php" to="*.php.bak" /> <fileset dir="./app" includes="**/*.php" /> • </copy> Sunday, 20 June 2010
  • 13. Phing: Filesystem Transformation • Other kind of mappers present: • Flatten Mapper: Gets base filename • Regex Mapper: Changes filenames based on regular expressions • Merge Mapper: change all source filenames to the same name Sunday, 20 June 2010
  • 14. Phing: Data Transformation • <filterchain> is used to transform the contents of the file. Supported by many tasks like <copy>, <move> etc • Can perform various actions: • Strip comments from your files • Replace values in your file • Perform XSLT Transformations • Above all your chain these transformations Sunday, 20 June 2010
  • 15. Phing: Data Transformation <copy todir="${build}/htdocs"> <fileset includes="*.html" /> <filterchain> <replaceregexp> <regexp pattern="rn" replace="n" /> </replaceregexp> <tidyfilter encoding="utf8"> <config name="indent" value="true" /> </tidyfilter> </filterchain> </copy> Sunday, 20 June 2010
  • 16. Phing: Data Transformation • <headfilter> Reads only the first n lines of the file • <linecontains> Filters out lines that contain a specific word • <linecontainsregexp> Filters out lines that contain a specific regular expression • <prefixlines> Adds stuff to the lines of the selected files • <tabtospaces> Converts tabs to spaces (HURRAH!!) Sunday, 20 June 2010
  • 17. Phing: More Data Transformations • <StripPHPComments> Takes out php comments • <replaceregexp> • <replacetokens> This can particularly be handy for spec files Sunday, 20 June 2010
  • 18. Phing: Data Transformations • Consider a file that contains: The current user is ##current_user## • Use this build target to replace the token <property environment="env" /> <filterchain> <replacetokens begintoken="##" endtoken="##"> <token key="CURRENT" value="${env.LOGNAME}" /> <replacetoken> </filterchain> Sunday, 20 June 2010
  • 19. Phing: Packaging • Tasks like <tar> <zip> can compress and package the set of files you want to compress • <pearpkg> and <pearpkg2> allows you to build pear package using phing Sunday, 20 June 2010
  • 20. Phing: Version Control and Deployment • <svn*> tasks provide support for subversion: • <svncheckout> • <svncommit> • <svnexport> • <svnlastrevision> • <scp> to move files to another server • Support for CSV also present Sunday, 20 June 2010
  • 21. Phing: Support for DB Migration • <pdosqlexec> and <creole> provides execution of database statements • <dbdeploy> can take care of db migrations http://dbdeploy.com/documentation/getting-started/rules-for- using-dbdeploy/ • Drupal Deployment solution anyone? Sunday, 20 June 2010
  • 22. Phing: Validating Code • <jslint> using an external utility jsl • <xmllint> uses internal DOM support for validating against given schema file • <phplint> just uses php -l • <tidy> can be use to validate markup and cleanup html Sunday, 20 June 2010
  • 23. Phing: Php API Docs • Support for phpDocumentor <phpdoc title="API Documentation" destdir="apidocs" sourcecode="no" output="HTML:Smarty:PHP"> <fileset dir="./classes"> <include name="**/*.php" /> </fileset> </phpdoc> Sunday, 20 June 2010
  • 24. Phing: Extending Functionalities • Two ways to extend Phing: • Embed PHP in the build file itself (not the cleanest solution) • Write your own class to provide any of the following functioanlity: • Task • Type • Selector • Filter • and more... Sunday, 20 June 2010
  • 25. Phing: Extending Functionality • <phpevaltask> lets you set a property to the results of evaluating a PHP Expression or the results by a function call. <php function="crypt" returnProperty="enc_passwd"> <param value="${auth.root_passwd}"/> </php> <php expression="3 + 4" returnProperty="sum"/> <php expression="echo 'test';"> Sunday, 20 June 2010
  • 26. Phing: Extending Functionality • <adhoc-task> allows you to define a task within your build file. Sunday, 20 June 2010
  • 27. Phing: Extending Functionality <target name="main" description="==>test AdhocTask "> <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="B.L.I.N.G"/> </target> Sunday, 20 June 2010
  • 28. Phing: Scripting & Logic • Phing also supports conditional tags <if> <equals arg1="${foo}" arg2="bar" /> <then> <echo message="The value of property foo is 'bar'" /> </then> </elseif> <else> <echo message="The value of property foo is not 'foo' or 'bar'" /> </else> </if> Sunday, 20 June 2010
  • 29. Phing: Writing a custom task require_once "phing/Task.php"; class MyEchoTask extends Task { /** * The message passed in the buildfile. */ private $message = null; /** * The setter for the attribute "message" */ public function setMessage($str) { $this->message = $str; } /** * The init method: Do init steps. */ public function init() { // nothing to do here } /** * The main entry point method. */ public function main() { print($this->message); Sunday, 20 June 2010 }
  • 30. Phing: Using the <myecho> task <?xml version="1.0" ?> <project name="test" basedir="." default="myecho"> <taskdef name="myecho" classname="phing.tasks.my.MyEcho" /> <target name="test.myecho"> <myecho message="Hello World" /> </target> </project> Sunday, 20 June 2010
  • 31. What Next? F P C I P Sunday, 20 June 2010