Advertisement
Advertisement

More Related Content

Advertisement

Automation with phing

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

  1. Symbolizes we are not perfect.
  2. No challenge in manual busy work. Less attention given.
  3. At the end you get faster, more efficient processes, with less errors.&lt;mention ct deployer?&gt;
  4. Branching, Tagging, and several standalone servers for their own purpose.
  5. Saves you time, don’t need to reinvent the wheel
  6. not build file passed defaults to build.xml in current dirno target name passed defaults to project default target in build file
  7. logical grouping of tasks to achieve a goalmultiple depends with comma delimited
  8. Where the real work happens.Optional are installed through dependencies.You can create your own which will be covered later.
  9. Mention override=“true” to override property values.
  10. Excludes allows excluding files, class, and methods.
  11. ExpandProperty great to replace environment specific variablesFlatten remove directory from filename.Glob is copy/rename.RegExp replaces filename using expression.
  12. Can also have elseif and else.
  13. Talk about ssh keys for scp/ssh
  14. Good when there isn’t a task you need - and rather not create your own.
  15. Obfuscation.
  16. All cron’d but Prod
  17. Lean mean fighting machine.
Advertisement