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

Phar, The PHP .exe Format

on

  • 7,253 views

 

Statistics

Views

Total Views
7,253
Views on SlideShare
5,089
Embed Views
2,164

Actions

Likes
4
Downloads
31
Comments
0

5 Embeds 2,164

http://sasezaki.hatenablog.com 2151
http://a0.twimg.com 8
http://webcache.googleusercontent.com 2
http://www.php-talks.com 2
https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Phar, The PHP .exe Format Phar, The PHP .exe Format Presentation Transcript

  • Phar, The PHP .exe format Helgi Þormar Þorbjörnsson PHP Benelux, 27th of January 2012Friday, 27 January 12
  • Who am I?Friday, 27 January 12
  • Helgi Co-founded Orchestra.io Work at EngineYard PEAR Developer From Iceland @h on TwitterFriday, 27 January 12
  • What is Phar?Friday, 27 January 12
  • Phar = PHP ArchiveFriday, 27 January 12
  • Similar to JAR ... But for PHPFriday, 27 January 12
  • Phar PHP Extension Built in / default from 5.3 onwards More Powerful than PHP_ArchiveFriday, 27 January 12
  • PEAR: PHP_Archive Reference implementation User Land Code Less Powerful Works on older PHP Not maintained anymoreFriday, 27 January 12
  • Phar unravelledFriday, 27 January 12
  • Simple yet flexible File FormatFriday, 27 January 12
  • Pack multiple files into oneFriday, 27 January 12
  • PharFriday, 27 January 12
  • Similar to TarFriday, 27 January 12
  • The special sauce 1. Stub 2. Manifest 3. File Contents 4. Signature (optional)Friday, 27 January 12
  • Manifest List of Files File Permission File Compression Meta DataFriday, 27 January 12
  • Compression Whole Archive Per file Available Compressions gzip, bz2 and zipFriday, 27 January 12
  • Stub Piece of PHP code Bootstraping AutoloaderFriday, 27 January 12
  • Get all the code used in this talk and more! https://github.com/helgi/phar-talkFriday, 27 January 12
  • Going more practicalFriday, 27 January 12
  • Normal IncludeFriday, 27 January 12
  • Phar IncludeFriday, 27 January 12
  • Phar works via StreamsFriday, 27 January 12
  • Streams Usage fopen / fwrite / fclose file_get_contents opendir / rmdir / mkdir anything that works with streamsFriday, 27 January 12
  • Friday, 27 January 12
  • Does not extract to diskFriday, 27 January 12
  • Works on web and CLIFriday, 27 January 12
  • Can be ran without the extensionFriday, 27 January 12
  • Why use Phar?Friday, 27 January 12
  • Full ApplicationsFriday, 27 January 12
  • CLI Applications Pyrus PHPUnitFriday, 27 January 12
  • Web ApplicationsFriday, 27 January 12
  • Setup Tools go-pear.phar PEAR installation in PHP buildsFriday, 27 January 12
  • Supporting CodeFriday, 27 January 12
  • Plugins LithiumFriday, 27 January 12
  • ThemesFriday, 27 January 12
  • Libraries SilexFriday, 27 January 12
  • Handy Packaging!Friday, 27 January 12
  • Executable file for applications!Friday, 27 January 12
  • Pros and ConsFriday, 27 January 12
  • Pros Single download with all dependencies Run multiple versions in parallel Upgrades are easy No unpacking Security against modificationsFriday, 27 January 12
  • 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
  • StubsFriday, 27 January 12
  • Bootstrap for pharFriday, 27 January 12
  • Smallest possible StubFriday, 27 January 12
  • __HALT_COMPILER() is a minimum requirementFriday, 27 January 12
  • Not used when phar file is used via streamsFriday, 27 January 12
  • Web PharFriday, 27 January 12
  • Phar::interceptFileFuncs() Phar::mungServer() Phar::WebPharFriday, 27 January 12
  • CLI PharFriday, 27 January 12
  • No Phar::WebPhar() Simple file include Shebang for easy executionFriday, 27 January 12
  • Web and CLI PharFriday, 27 January 12
  • CLI + AutoloadFriday, 27 January 12
  • CLI + Autoload cli.php a.php b.phpFriday, 27 January 12
  • Phar offers a default stubFriday, 27 January 12
  • Will work for mostFriday, 27 January 12
  • Extracts to temp dir if Phar is not availableFriday, 27 January 12
  • PerformanceFriday, 27 January 12
  • Works with APCFriday, 27 January 12
  • Works on files inside the archiveFriday, 27 January 12
  • Remember, everything goes via PHP Extract static files to a directory and serve from thereFriday, 27 January 12
  • SecurityFriday, 27 January 12
  • Phar disallows writing by defaultFriday, 27 January 12
  • Suhosin Enabled by default in Debian and UbuntuFriday, 27 January 12
  • Signatures are used to check the integrity of the archiveFriday, 27 January 12
  • Signature Hashes: OpenSSL MD5 SHA1 SHA256 SHA512Friday, 27 January 12
  • Hashes By default executable Phar is signed SHA1 Tar / Zip are not unless specifiedFriday, 27 January 12
  • Extra Goodies!Friday, 27 January 12
  • Phar::mount() Mount external files, such as config, into the phar archiveFriday, 27 January 12
  • 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
  • Useful Tools phar-util https://github.com/koto/phar-util empir http://empir.sourceforge.net/Friday, 27 January 12
  • Get all the code used in this talk and more! https://github.com/helgi/phar-talkFriday, 27 January 12
  • Come to the winter party tomorrow! Beer and food is on me :-) And some awesome swag!Friday, 27 January 12
  • Questions? @h helgi@engineyard.com https://github.com/helgi/phar-talk Joind.in: http://joind.in/4755Friday, 27 January 12