Was sind PHARs eigentlich?
๏ PHARs sind (ausführbare) gepackte PHP
Applikationen
๏ PHP-eigenes Format, aber konvertierbar
nach ZIP und TAR
๏ Kann mit der PHAR Extension oder
PEAR\PHP_Archive erstellt werden
๏ Lese-/Schreibzugriff über StreamWrapper
1 Einführung in PHAR Tools
php.ini
[Phar]
; http://php.net/phar.readonly
;phar.readonly = On
; http://php.net/phar.require-hash
;phar.require_hash = On
;phar.cache_list =
Einführung in PHAR Tools
1
Slide 7
Slide 7 text
php.ini
[Phar]
; http://php.net/phar.readonly
;phar.readonly = On
phar.readonly = Off
; http://php.net/phar.require-hash
;phar.require_hash = On
;phar.cache_list =
Einführung in PHAR Tools
1
Slide 8
Slide 8 text
Einführung in PHAR Tools
1
Automate everything!
Slide 9
Slide 9 text
Einführung in PHAR Tools
1
PHAR Tools vs. Tool-Scripts:
๏ Kaum Mehraufwand
๏ Beliebige Komplexität und Größe
๏ Einfach zu verteilen und zu aktualisieren
๏ Nicht ohne weiteres manipulierbar
๏ Herkunft kann verifiziert werden
๏ Dependency Encapsulation
Slide 10
Slide 10 text
Einführung in PHAR Tools
1
Console /
Process
BOX
Project
Dependency
Manager
Slide 11
Slide 11 text
Einführung in PHAR Tools
1
Features Symfony Console:
๏ Coloured Logging / Verbosity-Levels
๏ App-Struktur / Commands
๏ Input / Output Interfaces
๏ Optionen und Argumente Handling
๏ Diverse Helpers
๏ Hilfe
Slide 12
Slide 12 text
Einführung in PHAR Tools
1
Features BOX Project:
๏ Einfache Config für das PHAR-Building
๏ Placeholder z.B. für GIT-Version
๏ Stubbing für CLI Executables
๏ Include/Exclude Files
๏ Signing / Verifying mit OpenSSL Key
PHARs verteilen & updaten
3
Tipps für die Verteilung:
๏ Eigenes Repo für die PHARs
๏ Versionierung nach SemVer (ohne “v”!)
๏ Permalink für den latest Build
๏ Katalog für alle Builds (JSON)
Slide 18
Slide 18 text
PHARs verteilen & updaten
3
Install / Update-Strategien:
๏ Self-Hosted
๏ GitHub als Download zum Release
๏ PhiVE / PHAR.IO
Slide 19
Slide 19 text
VIELEN DANK!
@hollodotme
@phpindd
phpind.de
github.com/hollodotme
github.com/PHPinDD
www.fortuneglobe.com
www.phpug-dresden.de
@phpugdd
HOLGER
WOLTERSDORF
slides available
on slideshare
Slide 20
Slide 20 text
Appendix
A
Links / Quellen:
๏ Official PHAR documentation: http://php.net/phar
๏ Symfony Console Component: http://symfony.com/doc/current/components/console
๏ Symfony Process Component: http://symfony.com/doc/current/components/process
๏ BOX-Project (GitHub): https://github.com/box-project/box2
๏ BOX-Project Documentation: http://box-project.github.io/box2/
๏ PHAR-Update Lib: https://packagist.org/packages/herrera-io/phar-update
๏ Blog-Post “Distributing a PHP CLI app with ease” by Matthieu Moquet (@MattKetmo):
https://moquet.net/blog/distributing-php-cli/
๏ Blog Post “Secure PHAR Automation” by Matthew Weier O’Phinney: https://mwop.net/
blog/2015-12-14-secure-phar-automation.html
๏ PHAR Updater:
๏ https://github.com/padraic/phar-updater
๏ https://github.com/kherge-abandoned/php-phar-update
๏ Example-Tools: https://github.com/PHPinDD/phar-better-tool-example
๏ Example-Distribution: https://github.com/PHPinDD/phar-better-tool-distribution