Your SlideShare is downloading. ×
Phar, The PHP .exe Format
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Phar, The PHP .exe Format

7,424

Published on

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
7,424
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
34
Comments
0
Likes
4
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. Phar, The PHP .exe format Helgi Þormar Þorbjörnsson PHP Benelux, 27th of January 2012Friday, 27 January 12
  • 2. Who am I?Friday, 27 January 12
  • 3. Helgi Co-founded Orchestra.io Work at EngineYard PEAR Developer From Iceland @h on TwitterFriday, 27 January 12
  • 4. What is Phar?Friday, 27 January 12
  • 5. Phar = PHP ArchiveFriday, 27 January 12
  • 6. Similar to JAR ... But for PHPFriday, 27 January 12
  • 7. Phar PHP Extension Built in / default from 5.3 onwards More Powerful than PHP_ArchiveFriday, 27 January 12
  • 8. PEAR: PHP_Archive Reference implementation User Land Code Less Powerful Works on older PHP Not maintained anymoreFriday, 27 January 12
  • 9. Phar unravelledFriday, 27 January 12
  • 10. Simple yet flexible File FormatFriday, 27 January 12
  • 11. Pack multiple files into oneFriday, 27 January 12
  • 12. PharFriday, 27 January 12
  • 13. Similar to TarFriday, 27 January 12
  • 14. The special sauce 1. Stub 2. Manifest 3. File Contents 4. Signature (optional)Friday, 27 January 12
  • 15. Manifest List of Files File Permission File Compression Meta DataFriday, 27 January 12
  • 16. Compression Whole Archive Per file Available Compressions gzip, bz2 and zipFriday, 27 January 12
  • 17. Stub Piece of PHP code Bootstraping AutoloaderFriday, 27 January 12
  • 18. Get all the code used in this talk and more! https://github.com/helgi/phar-talkFriday, 27 January 12
  • 19. Going more practicalFriday, 27 January 12
  • 20. Normal IncludeFriday, 27 January 12
  • 21. Phar IncludeFriday, 27 January 12
  • 22. Phar works via StreamsFriday, 27 January 12
  • 23. Streams Usage fopen / fwrite / fclose file_get_contents opendir / rmdir / mkdir anything that works with streamsFriday, 27 January 12
  • 24. Friday, 27 January 12
  • 25. Does not extract to diskFriday, 27 January 12
  • 26. Works on web and CLIFriday, 27 January 12
  • 27. Can be ran without the extensionFriday, 27 January 12
  • 28. Why use Phar?Friday, 27 January 12
  • 29. Full ApplicationsFriday, 27 January 12
  • 30. CLI Applications Pyrus PHPUnitFriday, 27 January 12
  • 31. Web ApplicationsFriday, 27 January 12
  • 32. Setup Tools go-pear.phar PEAR installation in PHP buildsFriday, 27 January 12
  • 33. Supporting CodeFriday, 27 January 12
  • 34. Plugins LithiumFriday, 27 January 12
  • 35. ThemesFriday, 27 January 12
  • 36. Libraries SilexFriday, 27 January 12
  • 37. Handy Packaging!Friday, 27 January 12
  • 38. Executable file for applications!Friday, 27 January 12
  • 39. Pros and ConsFriday, 27 January 12
  • 40. Pros Single download with all dependencies Run multiple versions in parallel Upgrades are easy No unpacking Security against modificationsFriday, 27 January 12
  • 41. Cons Incremental updates (no deltas) Upgrading is a manual process Web server may need changes Extending the application is harder README / INSTALL become hard to reachFriday, 27 January 12
  • 42. StubsFriday, 27 January 12
  • 43. Bootstrap for pharFriday, 27 January 12
  • 44. Smallest possible StubFriday, 27 January 12
  • 45. __HALT_COMPILER() is a minimum requirementFriday, 27 January 12
  • 46. Not used when phar file is used via streamsFriday, 27 January 12
  • 47. Web PharFriday, 27 January 12
  • 48. Phar::interceptFileFuncs() Phar::mungServer() Phar::WebPharFriday, 27 January 12
  • 49. CLI PharFriday, 27 January 12
  • 50. No Phar::WebPhar() Simple file include Shebang for easy executionFriday, 27 January 12
  • 51. Web and CLI PharFriday, 27 January 12
  • 52. CLI + AutoloadFriday, 27 January 12
  • 53. CLI + Autoload cli.php a.php b.phpFriday, 27 January 12
  • 54. Phar offers a default stubFriday, 27 January 12
  • 55. Will work for mostFriday, 27 January 12
  • 56. Extracts to temp dir if Phar is not availableFriday, 27 January 12
  • 57. PerformanceFriday, 27 January 12
  • 58. Works with APCFriday, 27 January 12
  • 59. Works on files inside the archiveFriday, 27 January 12
  • 60. Remember, everything goes via PHP Extract static files to a directory and serve from thereFriday, 27 January 12
  • 61. SecurityFriday, 27 January 12
  • 62. Phar disallows writing by defaultFriday, 27 January 12
  • 63. Suhosin Enabled by default in Debian and UbuntuFriday, 27 January 12
  • 64. Signatures are used to check the integrity of the archiveFriday, 27 January 12
  • 65. Signature Hashes: OpenSSL MD5 SHA1 SHA256 SHA512Friday, 27 January 12
  • 66. Hashes By default executable Phar is signed SHA1 Tar / Zip are not unless specifiedFriday, 27 January 12
  • 67. Extra Goodies!Friday, 27 January 12
  • 68. Phar::mount() Mount external files, such as config, into the phar archiveFriday, 27 January 12
  • 69. PharData Phar archives can be extracted to disk Can operate on non-phar gzip and tar extract and compress archives Like PDO for archives! :-)Friday, 27 January 12
  • 70. Useful Tools phar-util https://github.com/koto/phar-util empir http://empir.sourceforge.net/Friday, 27 January 12
  • 71. Get all the code used in this talk and more! https://github.com/helgi/phar-talkFriday, 27 January 12
  • 72. Come to the winter party tomorrow! Beer and food is on me :-) And some awesome swag!Friday, 27 January 12
  • 73. Questions? @h helgi@engineyard.com https://github.com/helgi/phar-talk Joind.in: http://joind.in/4755Friday, 27 January 12

×