SlideShare ist ein Scribd-Unternehmen logo
1 von 20
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

Weitere ähnliche Inhalte

Ähnlich wie PHAR better Tools

Schweine latein-vortrag
Schweine latein-vortragSchweine latein-vortrag
Schweine latein-vortrag
Ramon Wartala
 
Nagios Conference 2007 | Pluginprogrammierung in Perl by Wolfgang Barth
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
NETWAYS
 
Metaprogrammierung und Reflection
Metaprogrammierung und ReflectionMetaprogrammierung und Reflection
Metaprogrammierung und Reflection
Stefan Marr
 
Entwicklung mit Chef und Vagrant - PHPUG HH
Entwicklung mit Chef und Vagrant - PHPUG HHEntwicklung mit Chef und Vagrant - PHPUG HH
Entwicklung mit Chef und Vagrant - PHPUG HH
Florian Holzhauer
 

Ähnlich wie PHAR better Tools (20)

Composer und TYPO3
Composer und TYPO3Composer und TYPO3
Composer und TYPO3
 
20160229_ModernApplicationDevelopment_Python_KPatenge
20160229_ModernApplicationDevelopment_Python_KPatenge20160229_ModernApplicationDevelopment_Python_KPatenge
20160229_ModernApplicationDevelopment_Python_KPatenge
 
Schweine latein-vortrag
Schweine latein-vortragSchweine latein-vortrag
Schweine latein-vortrag
 
Cross Plattform Apps mit Visual Studio und Apache Cordova
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
 
Nagios Conference 2007 | Pluginprogrammierung in Perl by Wolfgang Barth
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
 
Abläufe mit PHP und Phing automatisieren
Abläufe mit PHP und Phing automatisierenAbläufe mit PHP und Phing automatisieren
Abläufe mit PHP und Phing automatisieren
 
fn project serverless computing
fn project serverless computingfn project serverless computing
fn project serverless computing
 
Migration zum Zend Framework 3
Migration zum Zend Framework 3Migration zum Zend Framework 3
Migration zum Zend Framework 3
 
Perl Renaissance Reloaded
Perl Renaissance ReloadedPerl Renaissance Reloaded
Perl Renaissance Reloaded
 
Einführung in Docker
Einführung in DockerEinführung in Docker
Einführung in Docker
 
Back 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 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
 
Metaprogrammierung und Reflection
Metaprogrammierung und ReflectionMetaprogrammierung und Reflection
Metaprogrammierung und Reflection
 
Tipps & Tricks für Erweiterungsentwickler - JoomlaDay Deutschland 2014 - Köln
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
 
Froscamp2010_padre
Froscamp2010_padreFroscamp2010_padre
Froscamp2010_padre
 
Web Entwicklung mit PHP - Teil 1
Web Entwicklung mit PHP - Teil 1Web Entwicklung mit PHP - Teil 1
Web Entwicklung mit PHP - Teil 1
 
Hands-on Workshop: API-Dokumentation mit OpenAPI / Swagger in ASP.NET Core
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
 
PHP5 und Oracle
PHP5 und OraclePHP5 und Oracle
PHP5 und Oracle
 
PHP-Applikationen mit PEAR
PHP-Applikationen mit PEARPHP-Applikationen mit PEAR
PHP-Applikationen mit PEAR
 
Entwicklung mit Chef und Vagrant - PHPUG HH
Entwicklung mit Chef und Vagrant - PHPUG HHEntwicklung mit Chef und Vagrant - PHPUG HH
Entwicklung mit Chef und Vagrant - PHPUG HH
 
Source Code Analyse - Ein praktikabler Ansatz
Source Code Analyse - Ein praktikabler AnsatzSource Code Analyse - Ein praktikabler Ansatz
Source Code Analyse - Ein praktikabler Ansatz
 

PHAR better Tools

  • 1.
  • 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

Hinweis der Redaktion

  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