Successfully reported this slideshow.

Automation with phing

6

Share

1 of 45
1 of 45

Automation with phing

6

Share

Download to read offline

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.

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

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 Example Deltas – 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.

Editor's Notes

  • 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.&lt;mention ct deployer?&gt;
  • 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.
  • ×