Phing

  • 3,914 views
Uploaded on

My Phing presentation from PHPLondon on 2nd September 2010.

My Phing presentation from PHPLondon on 2nd September 2010.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,914
On Slideshare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
56
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Tour credentials PHING
  • 2. WHO AM I? • Bournemouth Uni Graduate (2009) • Clock Employee (July 2007) • Synth Media Employee (November 2009) • Software Engineer • Web Developer • Deployment Guy DOM UDALL • Music Fiend • Wannabe Producer • Average Bassist JoeMcCabe @Synth Media
  • 3. SOCIAL MEDIA • domudall – srs. • weareclock – very srs. • dmno – not srs. IainGrant@Clock
  • 4. GENERIC PRE-TALK APOLOGY/ DISCLAIMER http://www.flickr.com/photos/g_fox/4291356662/
  • 5. Tour credentials WHAT IS PHING?
  • 6. PHING
  • 7. PHING IS
  • 8. PHING IS AWESOME
  • 9. WHAT IS PHING? PHing Is Not GNU make • Project build tool • Platform independent • Based on Apache Ant • Provides a simple OO model for extending • Uses XML build files • No required external dependencies • Open source • Built & optimised for ZendEngine2/PHP5
  • 10. WHY? • Improve product quality • Eliminate automatable tasks • Minimises error (bad builds) • Eliminate dependencies on key personnel • Save time and money
  • 11. HISTORY Andreas Anderhold • Originally a subproject of Binarycloud • Extensive use of XML for project metadata • Binarycloud built for PHP • Used GNU make, but had drawbacks • Ant written in Java • Phing used to “compile” metadata into PHP • Centralised project metadata (data model) • Build multi-language pages from one source Michiel Rook Hans Lellelid
  • 12. Tour credentials MANY MANY THINGS
  • 13. WHAT IT CAN DO • Lots – Not just for deployment • Provides interface to installed software • SVN tasks • PHPUnit/SimpleTest • Code analysis tasks • PhpDocumentor • PhpLint/JslLint/XmlLint • Zip/Unzip • File manipulation • Various OS tasks wordle.net
  • 14. WHY USE PHING? • Least common denominator • Provides single script entry point • Standardises common tasks • Ability to depend on other tasks • Highly extendible • Written in PHP
  • 15. GETTING STARTED Simple installation via PEAR $> pear channel‐discover pear.phing.info $> pear install phing/phing Or beta/RC version available via PEAR $> pear install phing/phing‐beta Also available from: • SVN • Zip Download
  • 16. BUILD FILE
  • 17. $> phing ‐l Buildfile: /var/application/Project/build.xml [property] Loading /var/application/Project/build.properties Default target: ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ document  Builds the documentation for this project Main targets: ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ document  Builds the documentation for this project Subtargets: ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ cleanDocumentPath
  • 18. WHAT CLOCK DID • Started using Xinc for continuous integration • ... Kind of. • Regular SVN exports to staging environments • Constructing zip files of project ‘widgets’ • Still only doing single server deployments • Following a long-winded / prone to error doc
  • 19. Tour credentials DEPLOYMENT
  • 20. THE OLD WAY
  • 21. <target name="phplint"> <phplint> LEARNING CURVE ... </phplint> </target> • Introduced facade targets <target name="codesniff" depends="phplint"> <phpcodesniffer standard="PEAR"  format="summary"> ... </phpcodesniffer> </target> <target name="phpunit" depends="codesniff"> <phpunit> ... </phpunit> </target>
  • 22. <target name="phplint"> <phplint> LEARNING CURVE ... </phplint> </target> • Introduced facade targets <target name="codesniff" depends="phplint"> <phpcodesniffer standard="PEAR"  format="summary"> ... </phpcodesniffer> </target> <target name="phpunit" depends="codesniff"> <phpunit> ... </phpunit> </target> <target name= "total‐report" depends="phplint,  codesniff, phpunit" description=“Creates  reports for project quality." />
  • 23. LEARNING CURVE • Introduced facade targets • Moved all the properties out
  • 24. LEARNING CURVE • Introduced facade targets • Moved all the properties out • Used properties for configurability
  • 25. <target name="phplint‐report"> <phplint> LEARNING CURVE <fileset dir="${build.src}"> <include name="**/*.php"/> </fileset> </phplint> • Introduced facade targets </target>  • Moved all the properties out <target name="sniff‐report”> <phpcodesniffer standard="PEAR"  format="summary"> • Used properties for configurability <fileset dir="${build.src}"> <include name="**/*.php"/> • Defined and reused elements with ids </fileset> </phpcodesniffer> </target>
  • 26. <fileset id="src_artifacts"  dir="${build.src}"> LEARNING CURVE <include name="**/*.php"/> </fileset> <target name="phplint‐report"> • Introduced facade targets <phplint> <fileset refid="src_artifacts" /> • Moved all the properties out </phplint> </target>  • Used properties for configurability <target name="sniff‐report"> <phpcodesniffer standard="PEAR"  • Defined and reused elements with ids format="summary"> <fileset refid="src_artifacts" /> </phpcodesniffer> </target>
  • 27. • Version numbering LEARNING CURVE /css/structure.css?v=@VERSION‐NUMBER@ • Application bootstrap template • Introduced facade targets • Apache configuration template • Moved all the properties out • Additional Apache modules • Used properties for configurability • Cron-related template • Defined and reused elements with ids • Use of reflexives and replacements
  • 28. LEARNING CURVE • Introduced facade targets • Moved all the properties out • Used properties for configurability • Defined and reused elements with ids • Use of reflexives and replacements • Separating build files
  • 29. THE PHING WAY
  • 30. HOW TO PUT A SITE LIVE $> phing deployLive Which revision would you like to deploy? Which version number are you deploying? $> phing setupLive $> phing createDatabase Database to update? Host? Port? Password? Process deltas? Recreate database? OR $> phing updateDatabase Database to update? Host? Port? Password?
  • 31. Tour credentials DATABASE
  • 32. DATABASE CHANGES • Our first experience of extending Phing • DbDeploy task initially caused issues • All SQL required is saved to SVN • Broken down into schema and delta • Choice of complete recreation or update • On database creation, each file gets run • Record of files run gets stored in the DB • On update, delta files not run get executed • Has similar rollback facility to DbDeploy
  • 33. EXTENDING • Include phing/Task.php class • Use main() function to perform task • Use setX functions to pass through properties • Can use filesets too
  • 34. LIMITATIONS • Configuration changes not instant • Not everything available on all OSs • Can become monolithic • Undefined properties not raised as an error • No internal persistence of state • Little to no IDE support
  • 35. SUMMARY • Simplify repetitive tasks • Single entry point • Reduces project learning curve • Highly extendible • Eliminate dependencies on key personnel • Saves time • Minimises human error • Easier to explain over the phone • Really good for what we do
  • 36. MORE! WEBSITE http://phing.info MAILING LISTS users@phing.tigris.org dev@phing.tigris.org
  • 37. THANK YOU • Paul Serby • Clock Tech Team • Syd Nadim • Lucy Jack • James Jonathan Ainsworth FUELLED BY • Infadels: http://open.spotify.com/album/2BluVKnyc2suYnMcrZoM7n • Caravan Palace: http://open.spotify.com/album/0AQU2cTRwdbTHkkJLmZZpG • Two Door Cinema Club: http://open.spotify.com/album/7xujTLL1kWNWH7vKUhgVoi • Bonobo: http://open.spotify.com/album/412m7Fq2zFtCB9uwNNxNM0 • Yuksek: http://open.spotify.com/album/3iOJeCzNdLTSM5d1Xo4hK5 • Pablo Decoder: http://open.spotify.com/track/3TpVphH9rkzrimGvcNuSmx