SlideShare a Scribd company logo
1 of 32
Download to read offline
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

More Related Content

What's hot

Modern iframe programming
Modern iframe programmingModern iframe programming
Modern iframe programmingbenvinegar
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Chris 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 addonsLeevi Graham
 
Automation with phing
Automation with phingAutomation with phing
Automation with phingJoey Rivera
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIPaul 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 WordPressMarko 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
 

What's hot (9)

Modern iframe programming
Modern iframe programmingModern iframe programming
Modern iframe programming
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015
 
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
 
Epub ppt
Epub pptEpub ppt
Epub ppt
 
Automation with phing
Automation with phingAutomation with phing
Automation with phing
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino API
 
Web micro-framework BATTLE!
Web micro-framework BATTLE!Web micro-framework BATTLE!
Web micro-framework BATTLE!
 
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
 
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
 

Viewers also liked

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 testsNicolas 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 StreamsDavey 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 webJean-Pierre Vincent
 
Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP GeneratorsMark 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_performanceafup Paris
 
Understanding Craftsmanship SwanseaCon2015
Understanding Craftsmanship SwanseaCon2015Understanding Craftsmanship SwanseaCon2015
Understanding Craftsmanship SwanseaCon2015Marcello 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 PostgreSQLGabriele 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 2015Bruno 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 apacheafup 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 2016CiaranMcNulty
 
The Wonderful World of Symfony Components
The Wonderful World of Symfony ComponentsThe Wonderful World of Symfony Components
The Wonderful World of Symfony ComponentsRyan Weaver
 

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
 
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
 
Elastic Searching With PHP
Elastic Searching With PHPElastic Searching With PHP
Elastic Searching With PHP
 
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
 
Diving deep into twig
Diving deep into twigDiving deep into twig
Diving deep into twig
 
PHP5.5 is Here
PHP5.5 is HerePHP5.5 is Here
PHP5.5 is Here
 
Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP Generators
 
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)
 
Top tips my_sql_performance
Top tips my_sql_performanceTop tips my_sql_performance
Top tips my_sql_performance
 
Mocking Demystified
Mocking DemystifiedMocking Demystified
Mocking Demystified
 
Understanding Craftsmanship SwanseaCon2015
Understanding Craftsmanship SwanseaCon2015Understanding Craftsmanship SwanseaCon2015
Understanding Craftsmanship SwanseaCon2015
 
Why elasticsearch rocks!
Why elasticsearch rocks!Why elasticsearch rocks!
Why elasticsearch rocks!
 
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
 
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
 
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)
 
Performance serveur et apache
Performance serveur et apachePerformance serveur et apache
Performance serveur et apache
 
Caching on the Edge
Caching on the EdgeCaching on the Edge
Caching on the Edge
 
Behat 3.0 meetup (March)
Behat 3.0 meetup (March)Behat 3.0 meetup (March)
Behat 3.0 meetup (March)
 
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
 
The Wonderful World of Symfony Components
The Wonderful World of Symfony ComponentsThe Wonderful World of Symfony Components
The Wonderful World of Symfony Components
 

Similar to Automation using-phing

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
 
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 lifeBoyan 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 PhingMichiel Rook
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP ApplicationsPavan Kumar N
 
Large Files without the Trials
Large Files without the TrialsLarge Files without the Trials
Large Files without the TrialsJazkarta, 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 BCA4John 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 APIOliver Busse
 
The Dojo Toolkit An Introduction
The Dojo Toolkit   An IntroductionThe Dojo Toolkit   An Introduction
The Dojo Toolkit An IntroductionJeff Fox
 
Automating Web Application Deployment
Automating Web Application DeploymentAutomating Web Application Deployment
Automating Web Application DeploymentMathew 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 APIOliver Busse
 
Desktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumDesktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumBen 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.pptxNaglaaAbdelhady
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011Bachkoutou 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-20Michael Lihs
 

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
 
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
 
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
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
 
Large Files without the Trials
Large Files without the TrialsLarge Files without the Trials
Large Files without the Trials
 
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
 
"How Mozilla Uses Selenium"
"How Mozilla Uses Selenium""How Mozilla Uses Selenium"
"How Mozilla Uses Selenium"
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino API
 
The Dojo Toolkit An Introduction
The Dojo Toolkit   An IntroductionThe Dojo Toolkit   An Introduction
The Dojo Toolkit An Introduction
 
Automating Web Application Deployment
Automating Web Application DeploymentAutomating Web Application Deployment
Automating Web Application Deployment
 
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...
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
 
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
 
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-...
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino API
 
Desktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumDesktop Apps with PHP and Titanium
Desktop Apps with PHP and Titanium
 
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
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011
 
Oscon 2010
Oscon 2010Oscon 2010
Oscon 2010
 
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
 

Recently uploaded

React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...itnewsafrica
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sectoritnewsafrica
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 

Recently uploaded (20)

React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 

Automation using-phing

  • 1. Automation Using Phing rajat_pandit@ipcmedia.com 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