Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Presented by Joey Rivera
Introduction• Joey Rivera• Manger of Technology Development at  Cengage Learning• http://www.joeyrivera.com• @joeyrivera
Summary•   Why we need Phing•   Installing and Usage•   Extending•   Examples•   Our implementations
Problem  http://www.seniorark.com/Humor/Double%20Takes/crooked%20line.gif
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• Aut...
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 e...
Why Phing•   Automation•   Save time•   Less errors•   Tons of built-in    tasks and features
Install• http://www.phing.info• PEAR install  – pear channel-discover pear.phing.info  – pear install phing/phing  – Get n...
Dependencies     http://www.phing.info/docs/guide/stable/
Using Phing• Command line  – phing -v  – phing -f buildfile  – phing -f buildfile targetname  – phing  – phing -l  – phing...
Build File• XML file  – Project  – Targets  – Tasks  – Types and properties  – Filters  – Mappers  – Conditions
Example Build File        http://www.phing.info/docs/guide/stable/
Project Node• Requires one per build.xml• Requires a default target declaration• Optional attributes:  – name  – basedir  ...
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:  – FtpD...
Properties• Variables• global vs. target specific• Declaration  – inline  – external file  – input
Built-in Properties       http://www.phing.info/docs/guide/stable/
Property File• Text file              Example:• Good way to  organize variables  into one location• Useful for  environmen...
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• ...
Conditions• Used through the following  two tasks:                   Example:   – condition   – if• Compare using   –   eq...
Extending      $PHING_HOME                |-- bin                |-- classes• Can extend    | `-- phing                |  ...
Custom Task       http://www.phing.info/docs/guide/stable/
Examples•   Version Control•   Packaging•   Unit Testing•   Documentation•   Deployment•   DbDeploy•   Exec
Version Control• SVN• Git
Packaging• Tar• Zip• PharPackage
Unit Testing• PhpUnit• PhpUnitReport
Documentation• PhpDocumentor2  – http://www.phpdoc.org/
Documentation Cont.
Deploying• Copy• Scp• FtpDeploy
Database Deployment• DbDeploy  – Database change management tool  – Creates script file based on deltas  – Tracks db versi...
DbDeploy cont.• Create changelog table              http://www.phing.info/docs/guide/stable/
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   – E...
Tagging• From branch to Tag  – Diff between rev of last    release and last tag of    the same iteration
Before < After
Resources• http://www.phing.info/docs/guide/stable/• http://dbdeploy.com/• http://www.phpdoc.org/
Thanks!• http://www.joeyrivera.com• @joeyrivera• Special thanks to my wife Ashley Rivera  (http://cargocollective.com/ashl...
Upcoming SlideShare
Loading in …5
×

Automation with phing

5,428 views

Published on

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.

Published in: Technology
  • Be the first to comment

Automation with phing

  1. 1. Presented by Joey Rivera
  2. 2. Introduction• Joey Rivera• Manger of Technology Development at Cengage Learning• http://www.joeyrivera.com• @joeyrivera
  3. 3. Summary• Why we need Phing• Installing and Usage• Extending• Examples• Our implementations
  4. 4. Problem http://www.seniorark.com/Humor/Double%20Takes/crooked%20line.gif
  5. 5. Problem Cont.• We make mistakes• Manual process can be time consuming• Busy work is no fun
  6. 6. Our Goals• Identify manual process at work – daily, weekly, monthly processes• Analyze amount of time spent on those• Automate them
  7. 7. Our Before
  8. 8. Our After
  9. 9. Phing is• PHing Is Not GNU make• Build tool based on Ant• XML based build files• Written in PHP5• Flexible and extendable• Platform independent
  10. 10. Why Phing• Automation• Save time• Less errors• Tons of built-in tasks and features
  11. 11. Install• http://www.phing.info• PEAR install – pear channel-discover pear.phing.info – pear install phing/phing – Get necessary dependencies• Non-PEAR Install – Download – Configure multiple env variables
  12. 12. Dependencies http://www.phing.info/docs/guide/stable/
  13. 13. Using Phing• Command line – phing -v – phing -f buildfile – phing -f buildfile targetname – phing – phing -l – phing -debug
  14. 14. Build File• XML file – Project – Targets – Tasks – Types and properties – Filters – Mappers – Conditions
  15. 15. Example Build File http://www.phing.info/docs/guide/stable/
  16. 16. Project Node• Requires one per build.xml• Requires a default target declaration• Optional attributes: – name – basedir – description
  17. 17. Targets• Grouping of tasks• Can depend on other tasks
  18. 18. 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
  19. 19. Properties• Variables• global vs. target specific• Declaration – inline – external file – input
  20. 20. Built-in Properties http://www.phing.info/docs/guide/stable/
  21. 21. Property File• Text file Example:• Good way to organize variables into one location• Useful for environment specific files
  22. 22. Types• Used within a task Example:• More complex data variables – FileSet • PatternSet • * vs. ** – Excludes
  23. 23. 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
  24. 24. Conditions• Used through the following two tasks: Example: – condition – if• Compare using – equals – isset – contrains – istrue – available• Can nest – or – and – not
  25. 25. 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
  26. 26. Custom Task http://www.phing.info/docs/guide/stable/
  27. 27. Examples• Version Control• Packaging• Unit Testing• Documentation• Deployment• DbDeploy• Exec
  28. 28. Version Control• SVN• Git
  29. 29. Packaging• Tar• Zip• PharPackage
  30. 30. Unit Testing• PhpUnit• PhpUnitReport
  31. 31. Documentation• PhpDocumentor2 – http://www.phpdoc.org/
  32. 32. Documentation Cont.
  33. 33. Deploying• Copy• Scp• FtpDeploy
  34. 34. Database Deployment• DbDeploy – Database change management tool – Creates script file based on deltas – Tracks db version – Easy to move version forward or backwards – http://dbdeploy.com/
  35. 35. DbDeploy cont.• Create changelog table http://www.phing.info/docs/guide/stable/
  36. 36. DbDeploy ExampleDeltas – each representing Deploy file after running DbDeploy a version
  37. 37. DbDeploy Delta Example
  38. 38. Other• Exec – Can run any system command – OS specific
  39. 39. Our Implementation• Restoring our DB’s• Automate SVN Exports• Automate Tagging
  40. 40. Restoring DB’s• Dev, Test, Staging, QA, Prod• Environment specific data
  41. 41. 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
  42. 42. Tagging• From branch to Tag – Diff between rev of last release and last tag of the same iteration
  43. 43. Before < After
  44. 44. Resources• http://www.phing.info/docs/guide/stable/• http://dbdeploy.com/• http://www.phpdoc.org/
  45. 45. Thanks!• http://www.joeyrivera.com• @joeyrivera• Special thanks to my wife Ashley Rivera (http://cargocollective.com/ashleyrivera ) for the graphics and template.

×