Slides of my talk at PHP USERGROUP DRESDEN on 29.06.2016 bei Collab & Couch
* Example-Source-Code: https://github.com/PHPinDD/phar-better-tool-example
* Example-Distribution: https://github.com/PHPinDD/phar-better-tool-distribution
4. 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
PEARPHP_Archive erstellt werden
๏ Lese-/Schreibzugriff über StreamWrapper
1 Einführung in PHAR Tools
9. Einführung in PHAR Tools1
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
10. Einführung in PHAR Tools1
Console /
Process
BOX
Project
Dependency
Manager
11. Einführung in PHAR Tools1
Features Symfony Console:
๏ Coloured Logging / Verbosity-Levels
๏ App-Struktur / Commands
๏ Input / Output Interfaces
๏ Optionen und Argumente Handling
๏ Diverse Helpers
๏ Hilfe
12. Einführung in PHAR Tools1
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
17. PHARs verteilen & updaten3
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)
18. PHARs verteilen & updaten3
Install / Update-Strategien:
๏ Self-Hosted
๏ GitHub als Download zum Release
๏ PhiVE / PHAR.IO
20. AppendixA
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
Hinweis der Redaktion
built-in PHAR Extension erlaubt den Zugriff auf Dateien innerhalb einer PHAR
Vorteile von PHAR:
Kann auch ohne PHAR Extension included / aufgerufen werden
Sicherheit: Ist per Default read-only (gilt nicht für ZIP und TAR)
Zeige Example 1 in PHPStorm
readonly: Schränkt den Schreibzugriff auf PHARs ein (gilt nicht für ZIP/TAR)
require_hash: Erlaubt das Ausführen nur, wenn Signatur vorhanden
cache_list: Cached Inhalte von webPHARs
Zeige Example 1 (Hallo Welt), 2 (Console Stub) & 3 (WebPhar)
Next: Warum PHAR tools?
Wie haben wir bisher automatisiert?
Shell-Scripts
PHP-Tool Scripts
Cronjobs, die Applikationen aufrufen