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 programming
benvinegar
 
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
 

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

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
 
Why elasticsearch rocks!
Why elasticsearch rocks!Why elasticsearch rocks!
Why elasticsearch rocks!
tlrx
 
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
 

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

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
 
Automating Web Application Deployment
Automating Web Application DeploymentAutomating Web Application Deployment
Automating Web Application Deployment
Mathew Byrne
 
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
Hiroki Ohtsuka
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011
Bachkoutou Toutou
 

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

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

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