Automation with phing
Upcoming SlideShare
Loading in...5

Automation with phing



Presentation for Codeworks 2012 Atlanta. This presentation went through what Phing is, how to set it up, example, and how we implemented it with our applications.

Presentation for Codeworks 2012 Atlanta. This presentation went through what Phing is, how to set it up, example, and how we implemented it with our applications.



Total Views
Views on SlideShare
Embed Views



6 Embeds 145 116 25 1 1 1 1



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment
  • Symbolizes we are not perfect.
  • No challenge in manual busy work. Less attention given.
  • At the end you get faster, more efficient processes, with less errors.
  • Branching, Tagging, and several standalone servers for their own purpose.
  • Saves you time, don’t need to reinvent the wheel
  • not build file passed defaults to build.xml in current dirno target name passed defaults to project default target in build file
  • logical grouping of tasks to achieve a goalmultiple depends with comma delimited
  • Where the real work happens.Optional are installed through dependencies.You can create your own which will be covered later.
  • Mention override=“true” to override property values.
  • Excludes allows excluding files, class, and methods.
  • ExpandProperty great to replace environment specific variablesFlatten remove directory from filename.Glob is copy/rename.RegExp replaces filename using expression.
  • Can also have elseif and else.
  • Talk about ssh keys for scp/ssh
  • Good when there isn’t a task you need - and rather not create your own.
  • Obfuscation.
  • All cron’d but Prod
  • Lean mean fighting machine.

Automation with phing Automation with phing Presentation Transcript

  • Presented by Joey Rivera
  • Introduction• Joey Rivera• Manger of Technology Development at Cengage Learning•• @joeyrivera
  • Summary• Why we need Phing• Installing and Usage• Extending• Examples• Our implementations
  • Problem
  • Problem Cont.• We make mistakes• Manual process can be time consuming• Busy work is no fun
  • Our Goals• Identify manual process at work – daily, weekly, monthly processes• Analyze amount of time spent on those• Automate them
  • Our Before
  • Our After
  • Phing is• PHing Is Not GNU make• Build tool based on Ant• XML based build files• Written in PHP5• Flexible and extendable• Platform independent
  • Why Phing• Automation• Save time• Less errors• Tons of built-in tasks and features
  • Install•• PEAR install – pear channel-discover – pear install phing/phing – Get necessary dependencies• Non-PEAR Install – Download – Configure multiple env variables
  • Dependencies
  • Using Phing• Command line – phing -v – phing -f buildfile – phing -f buildfile targetname – phing – phing -l – phing -debug
  • Build File• XML file – Project – Targets – Tasks – Types and properties – Filters – Mappers – Conditions
  • Example Build File
  • Project Node• Requires one per build.xml• Requires a default target declaration• Optional attributes: – name – basedir – description
  • Targets• Grouping of tasks• Can depend on other tasks
  • Tasks• Single piece of executable code• Core: – Copy, Delete, Echo, Exec, Mo ve, Foreach, and more• Optional: – FtpDeploy, GitPush, PDOSQL Exec, Scp, Zip, and more
  • Properties• Variables• global vs. target specific• Declaration – inline – external file – input
  • Built-in Properties
  • Property File• Text file Example:• Good way to organize variables into one location• Useful for environment specific files
  • Types• Used within a task Example:• More complex data variables – FileSet • PatternSet • * vs. ** – Excludes
  • Filters and Mappers• Filters Transform data/file contents within a task – Tidy – ExpandProperty – StripPhpComments• Mappers are like filters for files and directories – Flatten – Glob – RegExp
  • Conditions• Used through the following two tasks: Example: – condition – if• Compare using – equals – isset – contrains – istrue – available• Can nest – or – and – not
  • Extending $PHING_HOME |-- bin |-- classes• Can extend | `-- phing | |-- filters | | `-- util – Tasks | |-- mappers – Types | | |-- parser |-- tasks – Mappers | | |-- ext | | |-- system – Ad hoc | | | `-- condition | | `-- user | `-- types |-- docs | `-- phing_guide `-- test |-- classes `-- etc
  • Custom Task
  • Examples• Version Control• Packaging• Unit Testing• Documentation• Deployment• DbDeploy• Exec
  • Version Control• SVN• Git
  • Packaging• Tar• Zip• PharPackage
  • Unit Testing• PhpUnit• PhpUnitReport
  • Documentation• PhpDocumentor2 –
  • Documentation Cont.
  • Deploying• Copy• Scp• FtpDeploy
  • Database Deployment• DbDeploy – Database change management tool – Creates script file based on deltas – Tracks db version – Easy to move version forward or backwards –
  • DbDeploy cont.• Create changelog table
  • DbDeploy ExampleDeltas – each representing Deploy file after running DbDeploy a version
  • DbDeploy Delta Example
  • Other• Exec – Can run any system command – OS specific
  • Our Implementation• Restoring our DB’s• Automate SVN Exports• Automate Tagging
  • Restoring DB’s• Dev, Test, Staging, QA, Prod• Environment specific data
  • Automate SVN Exports• Trunk to Dev – Export diff between last rev and newest rev• ‘Release’ Branch to Testing – Export diff between last rev and newest rev• Tag to Staging, QA, Prod – Export diff between last tag and newest tag
  • Tagging• From branch to Tag – Diff between rev of last release and last tag of the same iteration
  • Before < After
  • Resources•••
  • Thanks!•• @joeyrivera• Special thanks to my wife Ashley Rivera ( ) for the graphics and template.