PHAR better Tools

PHP in DD
PHP in DDPHP Software Developers at PHPinDD
PHAR better Tools
HOLGER WOLTERSDORF
CIO • FATHER • HUSBAND • PHP DEV
ORGA-MITGLIED DER
@hollodotme
@phpindd
phpind.de
github.com/hollodotme
github.com/PHPinDD
1 2 3
Einführung in
PHAR Tools
PHARs verteilen
& updaten
Anwendungs-
Beispiele
PhiVE
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
Hallo Welt!
<?php
$phar = new Phar( __DIR__ . '/hello.phar' );
$phar->buildFromDirectory( __DIR__ . '/HelloPHAR' );
$phar->setDefaultStub( 'bin/main.php' );
/makephar.php
<?php
echo 'Hello World!';
/HelloPHAR/bin/main.php
Einführung in PHAR Tools1
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 Tools1
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 Tools1
Einführung in PHAR Tools1
Automate
everything!
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
Einführung in PHAR Tools1
Console /
Process
BOX
Project
Dependency
Manager
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
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
Anwendungs-Beispiele2
Anwendungsbeispiele2
“Standard” PHAR Tools:
๏ Testing: phpunit / codecept
๏ Analysis: pdepend, phpcpd, phpcs, phploc,
phpmd, …
๏ Dependencies: composer, graph-composer
๏ und viele mehr…
Anwendungsbeispiele2
DEMO
PHARs verteilen
& updaten
3
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)
PHARs verteilen & updaten3
Install / Update-Strategien:
๏ Self-Hosted
๏ GitHub als Download zum Release
๏ PhiVE / PHAR.IO
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
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
1 of 20

Recommended

Log::Log4perl qw/:easy/ by
Log::Log4perl qw/:easy/Log::Log4perl qw/:easy/
Log::Log4perl qw/:easy/Thomas Fahle
1.6K views67 slides
TYPO3 Dokumentation mit ReStructuredText by
TYPO3 Dokumentation mit ReStructuredTextTYPO3 Dokumentation mit ReStructuredText
TYPO3 Dokumentation mit ReStructuredTextPeter Linzenkirchner
2.6K views24 slides
TYPO3 Translations by
TYPO3 Translations TYPO3 Translations
TYPO3 Translations Marcus Schwemer
4K views22 slides
Einfuehrung in die Erstellung von Software-Paketen mit dem RPM Package Manager by
Einfuehrung in die Erstellung von Software-Paketen mit dem RPM Package ManagerEinfuehrung in die Erstellung von Software-Paketen mit dem RPM Package Manager
Einfuehrung in die Erstellung von Software-Paketen mit dem RPM Package ManagerLenz Grimmer
1.9K views19 slides
FMK2014: FileMaker Plugin erzeugen by Christian Schmitz by
FMK2014: FileMaker Plugin erzeugen by Christian SchmitzFMK2014: FileMaker Plugin erzeugen by Christian Schmitz
FMK2014: FileMaker Plugin erzeugen by Christian SchmitzVerein FM Konferenz
3K views27 slides
GNU Bourne Again SHell by
GNU Bourne Again SHellGNU Bourne Again SHell
GNU Bourne Again SHellFabian Becker
958 views43 slides

More Related Content

Similar to PHAR better Tools

Composer und TYPO3 by
Composer und TYPO3Composer und TYPO3
Composer und TYPO3Peter Kraume
3.6K views25 slides
20160229_ModernApplicationDevelopment_Python_KPatenge by
20160229_ModernApplicationDevelopment_Python_KPatenge20160229_ModernApplicationDevelopment_Python_KPatenge
20160229_ModernApplicationDevelopment_Python_KPatengeKarin Patenge
235 views27 slides
Schweine latein-vortrag by
Schweine latein-vortragSchweine latein-vortrag
Schweine latein-vortragRamon Wartala
2.2K views35 slides
Cross Plattform Apps mit Visual Studio und Apache Cordova by
Cross Plattform Apps mit Visual Studio und Apache CordovaCross Plattform Apps mit Visual Studio und Apache Cordova
Cross Plattform Apps mit Visual Studio und Apache CordovaPeter Hecker
274 views42 slides
Nagios Conference 2007 | Pluginprogrammierung in Perl by Wolfgang Barth by
Nagios Conference 2007 |  Pluginprogrammierung in Perl by Wolfgang BarthNagios Conference 2007 |  Pluginprogrammierung in Perl by Wolfgang Barth
Nagios Conference 2007 | Pluginprogrammierung in Perl by Wolfgang BarthNETWAYS
52 views30 slides
Abläufe mit PHP und Phing automatisieren by
Abläufe mit PHP und Phing automatisierenAbläufe mit PHP und Phing automatisieren
Abläufe mit PHP und Phing automatisierenChristian Münch
2K views30 slides

Similar to PHAR better Tools(20)

Composer und TYPO3 by Peter Kraume
Composer und TYPO3Composer und TYPO3
Composer und TYPO3
Peter Kraume3.6K views
20160229_ModernApplicationDevelopment_Python_KPatenge by Karin Patenge
20160229_ModernApplicationDevelopment_Python_KPatenge20160229_ModernApplicationDevelopment_Python_KPatenge
20160229_ModernApplicationDevelopment_Python_KPatenge
Karin Patenge235 views
Schweine latein-vortrag by Ramon Wartala
Schweine latein-vortragSchweine latein-vortrag
Schweine latein-vortrag
Ramon Wartala2.2K views
Cross Plattform Apps mit Visual Studio und Apache Cordova by Peter Hecker
Cross Plattform Apps mit Visual Studio und Apache CordovaCross Plattform Apps mit Visual Studio und Apache Cordova
Cross Plattform Apps mit Visual Studio und Apache Cordova
Peter Hecker274 views
Nagios Conference 2007 | Pluginprogrammierung in Perl by Wolfgang Barth by NETWAYS
Nagios Conference 2007 |  Pluginprogrammierung in Perl by Wolfgang BarthNagios Conference 2007 |  Pluginprogrammierung in Perl by Wolfgang Barth
Nagios Conference 2007 | Pluginprogrammierung in Perl by Wolfgang Barth
NETWAYS52 views
Abläufe mit PHP und Phing automatisieren by Christian Münch
Abläufe mit PHP und Phing automatisierenAbläufe mit PHP und Phing automatisieren
Abläufe mit PHP und Phing automatisieren
Christian Münch2K views
Migration zum Zend Framework 3 by Ralf Eggert
Migration zum Zend Framework 3Migration zum Zend Framework 3
Migration zum Zend Framework 3
Ralf Eggert1.1K views
Back to the future - Plone 5.2 und Python 3 Migration am Beispiel Onkopedia by Andreas Jung
Back to the future - Plone 5.2 und Python 3 Migration am Beispiel OnkopediaBack to the future - Plone 5.2 und Python 3 Migration am Beispiel Onkopedia
Back to the future - Plone 5.2 und Python 3 Migration am Beispiel Onkopedia
Andreas Jung998 views
Metaprogrammierung und Reflection by Stefan Marr
Metaprogrammierung und ReflectionMetaprogrammierung und Reflection
Metaprogrammierung und Reflection
Stefan Marr1.2K views
Tipps & Tricks für Erweiterungsentwickler - JoomlaDay Deutschland 2014 - Köln by Viktor Vogel
Tipps & Tricks für Erweiterungsentwickler - JoomlaDay Deutschland 2014 - KölnTipps & Tricks für Erweiterungsentwickler - JoomlaDay Deutschland 2014 - Köln
Tipps & Tricks für Erweiterungsentwickler - JoomlaDay Deutschland 2014 - Köln
Viktor Vogel1.4K views
Hands-on Workshop: API-Dokumentation mit OpenAPI / Swagger in ASP.NET Core by Gregor Biswanger
Hands-on Workshop: API-Dokumentation mit OpenAPI / Swagger in ASP.NET CoreHands-on Workshop: API-Dokumentation mit OpenAPI / Swagger in ASP.NET Core
Hands-on Workshop: API-Dokumentation mit OpenAPI / Swagger in ASP.NET Core
Gregor Biswanger212 views
Entwicklung mit Chef und Vagrant - PHPUG HH by Florian Holzhauer
Entwicklung mit Chef und Vagrant - PHPUG HHEntwicklung mit Chef und Vagrant - PHPUG HH
Entwicklung mit Chef und Vagrant - PHPUG HH
Florian Holzhauer1.3K views
Source Code Analyse - Ein praktikabler Ansatz by Marc Ruef
Source Code Analyse - Ein praktikabler AnsatzSource Code Analyse - Ein praktikabler Ansatz
Source Code Analyse - Ein praktikabler Ansatz
Marc Ruef630 views

PHAR better Tools

  • 2. HOLGER WOLTERSDORF CIO • FATHER • HUSBAND • PHP DEV ORGA-MITGLIED DER @hollodotme @phpindd phpind.de github.com/hollodotme github.com/PHPinDD
  • 3. 1 2 3 Einführung in PHAR Tools PHARs verteilen & updaten Anwendungs- Beispiele PhiVE 4
  • 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
  • 5. Hallo Welt! <?php $phar = new Phar( __DIR__ . '/hello.phar' ); $phar->buildFromDirectory( __DIR__ . '/HelloPHAR' ); $phar->setDefaultStub( 'bin/main.php' ); /makephar.php <?php echo 'Hello World!'; /HelloPHAR/bin/main.php Einführung in PHAR Tools1
  • 6. 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 Tools1
  • 7. 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 Tools1
  • 8. Einführung in PHAR Tools1 Automate everything!
  • 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
  • 14. Anwendungsbeispiele2 “Standard” PHAR Tools: ๏ Testing: phpunit / codecept ๏ Analysis: pdepend, phpcpd, phpcs, phploc, phpmd, … ๏ Dependencies: composer, graph-composer ๏ und viele mehr…
  • 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

Editor's Notes

  1. 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)
  2. Zeige Example 1 in PHPStorm
  3. readonly: Schränkt den Schreibzugriff auf PHARs ein (gilt nicht für ZIP/TAR)
  4. 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?
  5. Wie haben wir bisher automatisiert? Shell-Scripts PHP-Tool Scripts Cronjobs, die Applikationen aufrufen
  6. NEXT: Helferlein
  7. NEXT: Symfony Console & BOX Project
  8. Zeige box.phar key:create, box.phar build box.phar verify
  9. Next: “Standard”-Tools
  10. NEXT: Helferlein
  11. Zeige Example 4 Zeige IceDump
  12. NEXT: Helferlein