More Related Content More from Helgi Þormar Þorbjörnsson More from Helgi Þormar Þorbjörnsson (17) Phar, The PHP .exe Format1. Phar, The PHP .exe
format
Helgi Þormar Þorbjörnsson
PHP Benelux, 27th of January 2012
Friday, 27 January 12
3. Helgi
Co-founded Orchestra.io
Work at EngineYard
PEAR Developer
From Iceland
@h on Twitter
Friday, 27 January 12
5. Phar
=
PHP Archive
Friday, 27 January 12
7. Phar
PHP Extension
Built in / default from 5.3 onwards
More Powerful than PHP_Archive
Friday, 27 January 12
8. PEAR: PHP_Archive
Reference implementation
User Land Code
Less Powerful
Works on older PHP
Not maintained anymore
Friday, 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 Data
Friday, 27 January 12
16. Compression
Whole Archive
Per file
Available Compressions
gzip, bz2 and zip
Friday, 27 January 12
17. Stub
Piece of PHP code
Bootstraping
Autoloader
Friday, 27 January 12
18. Get all the code used in
this talk and more!
https://github.com/helgi/phar-talk
Friday, 27 January 12
23. Streams Usage
fopen / fwrite / fclose
file_get_contents
opendir / rmdir / mkdir
anything that works with streams
Friday, 27 January 12
27. Can be ran without the
extension
Friday, 27 January 12
32. Setup Tools
go-pear.phar
PEAR installation in PHP builds
Friday, 27 January 12
34. Plugins
Lithium
Friday, 27 January 12
37. Handy
Packaging!
Friday, 27 January 12
40. Pros
Single download with all dependencies
Run multiple versions in parallel
Upgrades are easy
No unpacking
Security against modifications
Friday, 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 reach
Friday, 27 January 12
46. Not used when phar file
is used via streams
Friday, 27 January 12
50. No Phar::WebPhar()
Simple file include
Shebang for easy execution
Friday, 27 January 12
60. Remember, everything
goes via PHP
Extract static files to a directory
and serve from there
Friday, 27 January 12
63. Suhosin
Enabled by default in Debian and Ubuntu
Friday, 27 January 12
65. Signature
Hashes: OpenSSL
MD5
SHA1
SHA256
SHA512
Friday, 27 January 12
66. Hashes
By default executable Phar is signed SHA1
Tar / Zip are not unless specified
Friday, 27 January 12
68. Phar::mount()
Mount external files, such as config, into
the phar archive
Friday, 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-talk
Friday, 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/4755
Friday, 27 January 12