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.

Website releases made easy with the PEAR installer - Barcelona 2008


Published on

Published in: Technology
  • Be the first to comment

Website releases made easy with the PEAR installer - Barcelona 2008

  1. 1. Website releases made easy with the PEAR installer <ul><ul><li>Helgi Þormar Þorbjörnsson </li></ul></ul>Barcelona PHP Conference, September 2008
  2. 2. Who Am I ? <ul><li>An Icelandic guy with a weird name </li></ul><ul><li>iBuildings UK </li></ul><ul><li>PEAR Group member </li></ul><ul><li>PEAR Developer – among other things, the installer </li></ul><ul><li> maintainer </li></ul><ul><li>PEAR <insert-job-title> ;-) </li></ul>Saturday, September 27, 2008
  3. 3. How to pronounce my name <ul><li>Þormar Þorbjörnsson being my last name </li></ul><ul><li>ASCII version being Thormar Thorbjoernsson </li></ul><ul><li>Þ = Th and pronounced like That or a Thorn </li></ul><ul><li>Now you are more enlightened about this Icelandic thing called Thorn </li></ul>
  4. 4. Alternative, not a replacement <ul><ul><li>Deploying websites with the PEAR installer is an alternative, not a replacement for other approaches. </li></ul></ul>
  5. 5. Other alternatives <ul><li>FTP Upload </li></ul><ul><li>SCP / rsync </li></ul><ul><li>Capistrano </li></ul><ul><li>SVN / CVS / <insert fancy version control> deployment </li></ul><ul><li>etc etc etc </li></ul>
  6. 6. PEAR Installer features to the rescue <ul><li>Easy upgrading </li></ul><ul><li>Ability to depend on a PEAR installable packages </li></ul><ul><li>Easy to split websites into smaller parts and give each part their own release cycle </li></ul>
  7. 7. PEAR Installer features to the rescue <ul><li>Custom file roles </li></ul><ul><li>Custom tasks </li></ul><ul><li>Post installation tasks </li></ul>
  8. 8. Last but not least <ul><ul><li>Tasks, custom file roles and so on are done with something we are familiar with .... </li></ul></ul>
  9. 10. What is required <ul><li>The PEAR Installer </li></ul><ul><li>Knowledge how to package your code with the installer </li></ul><ul><li>A bit of know how and RTFM skills </li></ul><ul><li>And not being afraid to read the source ;-) </li></ul>
  10. 11. Dismantling your site <ul><li>Split your site into logical pieces </li></ul><ul><li>Do not split into as many packages as you can! </li></ul><ul><li>Micro management is bad, mmmmkay </li></ul>
  11. 12. Dismantling your site <ul><li>Each piece of site has its own package.xml file </li></ul><ul><li>The website it self (the core package) has its own package.xml which all the split off pieces will depend on </li></ul>
  12. 13. Dismantling your site Web Services Backend Frontend Forum Website
  13. 14. The packages we get <ul><li>Website </li></ul><ul><li>Website_Frontend </li></ul><ul><li>Website_WebServices </li></ul><ul><li>Website_Backend </li></ul><ul><li>Website_Forum </li></ul>
  14. 15. Something to take note of <ul><li>www roled files install straight into www_dir </li></ul><ul><li>Ways to get past that “shortcoming”: </li></ul><ul><ul><li>Maintain only one website on the server ;-) </li></ul></ul><ul><ul><li>Make every website have their own pear config and even their own user </li></ul></ul><ul><ul><li>Utilize the baseinstalldir attribute on the top dir in package.xml (Best way) </li></ul></ul>
  15. 16. Custom file roles <ul><li>This feature allows you to write your own file roles </li></ul><ul><li>PEAR supports php, test, data, www and src by default </li></ul><ul><li>People have written their own file roles for various whacky reasons: </li></ul><ul><ul><li>In relation to templates </li></ul></ul><ul><ul><li>Custom handling of data files </li></ul></ul><ul><ul><li>Just to name few </li></ul></ul>
  16. 17. Post installation tasks <ul><li>Handy feature for all the family </li></ul><ul><li>Write a simple PHP task that you can run after the installation </li></ul><ul><ul><li>Clean up after the installation, temp dirs or similar </li></ul></ul><ul><ul><li>DB setup / upgrade tool </li></ul></ul><ul><ul><li>vhost adding / updating </li></ul></ul><ul><ul><li>Prime Caches </li></ul></ul><ul><ul><li>And just about anything you can dream up </li></ul></ul>
  17. 18. Need to know about post install We do not run post install script auto! Quick output what it looks like to have a post install script around pear/pearweb has post-install scripts: /usr/share/PEAR/pearweb.php pearweb: Use &quot;pear run-scripts pear/pearweb&quot; to finish setup. DO NOT RUN SCRIPTS FROM UNTRUSTED SOURCES
  18. 19. Post install task <file name=&quot;postinstall.php&quot; role=&quot;php&quot;> <tasks:postinstallscript> <tasks:paramgroup> <tasks:id> askdb </tasks:id> <tasks:param> <tasks:name> yesno </tasks:name> <tasks:prompt> Install database? </tasks:prompt> <tasks:type> yesno </tasks:type> <tasks:default> y </tasks:default> </tasks:param> </tasks:paramgroup> </tasks:postinstallscript> </file>
  19. 20. Post install task pear run-scripts pear/pearweb Including external post-installation script &quot;/usr/share/PEAR/pearweb.php&quot; - any errors are in this script Inclusion succeeded running post-install script &quot;pearweb_postinstall->init()&quot; init succeeded Install database? [y] :
  20. 21. Post install task <ul><li>Add more task:param to tasks:paramsgroup so the user gets more questions / prompts per task </li></ul><ul><li>Has the ability to skip a param group based on user input </li></ul><ul><li>task:type currently has 3 different types </li></ul><ul><ul><li>string </li></ul></ul><ul><ul><li>password </li></ul></ul><ul><ul><li>yesno </li></ul></ul>
  21. 22. Update pearweb database? [y] : 1. Database driver : mysqli 2. Database User name : pear 3. Database password : pear 4. Database host : localhost 5. Database name : pear 1-5, 'all', 'abort', or Enter to continue:
  22. 23. Real world example <ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul>In package.xml look for pearweb.php and you see how we do it for Good place to study how things are built up
  23. 24. Puzzling the pieces together <ul><ul><li>Now we run these pseudo packages and we want to install only part of our website structure </li></ul></ul><ul><ul><li>pear install –alldeps Website_WebServices Website_Frontend Website_Backend </li></ul></ul><ul><ul><li>This will install your only those 3 parts of your website along site all the deps which one of those is the Website. </li></ul></ul>
  24. 25. Puzzling the pieces together Web Services Backend Frontend Website
  25. 26. Questions?
  26. 27. Special thanks to Cal Evans for the elephpant photo!
  27. 28. (Look for my articles) [email_address] Resources