standards a php developer should...
TRANSCRIPT
![Page 1: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/1.jpg)
STANDARDS A PHP DEVELOPER SHOULD KNOW
@movetodevnullsebastianfeldmann
Sebastian Feldmann
T E N
![Page 2: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/2.jpg)
STANDARDS ARE
EVERYWHERE
![Page 3: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/3.jpg)
![Page 4: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/4.jpg)
![Page 5: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/5.jpg)
![Page 6: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/6.jpg)
![Page 7: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/7.jpg)
![Page 8: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/8.jpg)
The web is build on standards
![Page 9: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/9.jpg)
![Page 10: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/10.jpg)
![Page 11: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/11.jpg)
![Page 12: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/12.jpg)
💩 encodingUTF8
UTF16
ISO8859-1
ANSI
CP1252
ASCIIEBCDIC273
![Page 13: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/13.jpg)
w w w . p h p - f i g . o r gPHP-FIG
![Page 14: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/14.jpg)
•Composer
•Drupal
• Joomla
•Magento
•ReactPHP
• Slim
• Symfony
• Zend Framework
•…
![Page 15: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/15.jpg)
PSR vs. RFC
![Page 16: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/16.jpg)
PSR2 PSR12PSR1
![Page 17: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/17.jpg)
Coding Standards
![Page 18: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/18.jpg)
![Page 19: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/19.jpg)
<?php namespace Vendor\Package;
use FooInterface; use BarClass as Bar; use OtherVendor\OtherPackage\BazClass;
class Foo extends Bar implements FooInterface { public function sampleMethod($a, $b = null) { if ($a === $b) { bar(); } elseif ($a > $b) { $foo->bar($arg1); } else { BazClass::bar($arg2, $arg3); } }
final public static function bar() { // method body } }
![Page 20: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/20.jpg)
<?php namespace Vendor\Package;
class Foo extends Bar implements FooInterface { public function sampleMethod($a, $b = null) { if ($this->someImportantProperty === $this->someEvenMoreImportantProperty && $this->currentState !== self::SOME_STATE_YOU_DONT_WANT) { throw new \RuntimeException('Something went wrong!'); }
... }
...
![Page 21: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/21.jpg)
<?php namespace Vendor\Package;
class Foo extends Bar implements FooInterface { public function sampleMethod($a, $b = null) { if ( $this->someImportantProperty === $this->someEvenMoreImportantProperty && $this->currentState !== self::SOME_STATE_YOU_DONT_WANT ) { throw new \RuntimeException('Something went wrong!'); }
... }
...
![Page 22: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/22.jpg)
<?php namespace Vendor\Package;
class Foo extends Bar implements FooInterface { public function sampleMethod($a, $b = null) { $foo = 'some super string';$bar = 'some other stuff';
... }
...
![Page 23: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/23.jpg)
<?php namespace Vendor\Package;
class Foo extends Bar implements FooInterface { public function sampleMethod($a, $b = null) { $foo = 'some super string’; $bar = 'some other stuff';
... }
...
![Page 24: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/24.jpg)
PHP Code Sniffer
PHP Coding Standard Fixer
![Page 25: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/25.jpg)
PSR4PSR0
![Page 26: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/26.jpg)
Autoloading
![Page 27: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/27.jpg)
Namespace
![Page 28: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/28.jpg)
<NamespaceName>(_<SubNamespaceNames>)*_<ClassName>
PHPUnit_Framework_TestCase
PHPUnit
Framework
TestCase.php
\PHPUnit\Framework\TestCase
\<NamespaceName>(\<SubNamespaceNames>)*\<ClassName>
src PHPUnit=>
PSR0
![Page 29: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/29.jpg)
<NamespaceName>(_<SubNamespaceNames>)*_<ClassName>
PHPUnit_Framework_TestCase
Framework
TestCase.php
\PHPUnit\Framework\TestCase
\<NamespaceName>(\<SubNamespaceNames>)*\<ClassName>
src
PHPUnit PHPUnit=> Framework
TestCase.php
src PHPUnit=>
PSR4
![Page 30: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/30.jpg)
![Page 31: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/31.jpg)
{
...
"autoload": { "psr-4": { "MyNamespace\\": "src/", }, "psr-0": { "OldLib_Lib1_": "libs/lib1", "SomeLib\\Lib2": "libs/lib2" } }
...
}
composer.json
![Page 32: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/32.jpg)
PSR3
![Page 33: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/33.jpg)
Logging
![Page 34: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/34.jpg)
<?php
namespace Psr\Log;
interface LoggerInterface { public function emergency($message, array $context = array());
public function alert($message, array $context = array()); public function critical($message, array $context = array()); public function error($message, array $context = array());
public function warning($message, array $context = array());
public function notice($message, array $context = array());
public function info($message, array $context = array());
public function debug($message, array $context = array());
public function log($level, $message, array $context = array()); }
![Page 35: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/35.jpg)
<?php
namespace Psr\Log;
interface LoggerInterface { public function emergency($message, array $context = array());
public function alert($message, array $context = array()); public function critical($message, array $context = array()); public function error($message, array $context = array());
public function warning($message, array $context = array());
public function notice($message, array $context = array());
public function info($message, array $context = array());
public function debug($message, array $context = array());
public function log($level, $message, array $context = array()); }
![Page 36: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/36.jpg)
<?php
namespace Psr\Log;
interface LoggerInterface { public function emergency($message, array $context = array());
public function alert($message, array $context = array()); public function critical($message, array $context = array()); public function error($message, array $context = array());
public function warning($message, array $context = array());
public function notice($message, array $context = array());
public function info($message, array $context = array());
public function debug($message, array $context = array());
public function log($level, $message, array $context = array()); }
![Page 37: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/37.jpg)
<?php
namespace Psr\Log;
interface LoggerAwareInterface { public function setLogger(LoggerInterface $logger); }
![Page 38: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/38.jpg)
<?php
namespace Psr\Log;
class LogLevel { const EMERGENCY = 'emergency'; const ALERT = 'alert'; const CRITICAL = 'critical'; const ERROR = 'error'; const WARNING = 'warning'; const NOTICE = 'notice'; const INFO = 'info'; const DEBUG = 'debug'; }
![Page 39: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/39.jpg)
<?php declare(strict_types=1);
namespace Monolog;
...
class Logger implements LoggerInterface { ...
}
![Page 40: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/40.jpg)
PSR16PSR6
![Page 41: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/41.jpg)
Caching
![Page 42: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/42.jpg)
<?php
namespace Psr\Cache;
interface CacheItemInterface { public function getKey();
public function get();
public function isHit(); public function set($value); public function expiresAt($expiration); public function expiresAfter($time); }
PSR6
![Page 43: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/43.jpg)
<?php
namespace Psr\Cache;
interface CacheItemInterface { public function getKey();
public function get();
public function isHit(); public function set($value); public function expiresAt($expiration); public function expiresAfter($time); }
PSR6
![Page 44: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/44.jpg)
<?php
namespace Psr\Cache;
interface CacheItemInterface { public function getKey();
public function get();
public function isHit(); public function set($value); public function expiresAt($expiration); public function expiresAfter($time); }
PSR6
![Page 45: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/45.jpg)
<?php
namespace Psr\Cache;
interface CacheItemInterface { public function getKey();
public function get();
public function isHit(); public function set($value); public function expiresAt($expiration); public function expiresAfter($time); }
PSR6
![Page 46: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/46.jpg)
<?php
namespace Psr\Cache;
interface CacheItemInterface { public function getKey();
public function get();
public function isHit(); public function set($value); public function expiresAt($expiration); public function expiresAfter($time); }
PSR6
![Page 47: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/47.jpg)
<?php
namespace Psr\Cache;
interface CacheItemPoolInterface { public function getItem($key);
public function getItems(array $keys = array());
public function hasItem($key);
public function clear(); public function deleteItem($key);
public function deleteItems(array $keys);
public function save(CacheItemInterface $item);
public function saveDeferred(CacheItemInterface $item);
public function commit(); }
PSR6
![Page 48: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/48.jpg)
<?php
namespace Psr\Cache;
interface CacheItemPoolInterface { public function getItem($key);
public function getItems(array $keys = array());
public function hasItem($key);
public function clear(); public function deleteItem($key);
public function deleteItems(array $keys);
public function save(CacheItemInterface $item);
public function saveDeferred(CacheItemInterface $item);
public function commit(); }
PSR6
![Page 49: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/49.jpg)
<?php
namespace Psr\Cache;
interface CacheItemPoolInterface { public function getItem($key);
public function getItems(array $keys = array());
public function hasItem($key);
public function clear(); public function deleteItem($key);
public function deleteItems(array $keys);
public function save(CacheItemInterface $item);
public function saveDeferred(CacheItemInterface $item);
public function commit(); }
PSR6
![Page 50: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/50.jpg)
<?php
namespace Psr\Cache;
interface CacheItemPoolInterface { public function getItem($key);
public function getItems(array $keys = array());
public function hasItem($key);
public function clear(); public function deleteItem($key);
public function deleteItems(array $keys);
public function save(CacheItemInterface $item);
public function saveDeferred(CacheItemInterface $item);
public function commit(); }
PSR6
![Page 51: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/51.jpg)
stop
stop
that’s too much
![Page 52: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/52.jpg)
<?php
namespace Psr\SimpleCache;
interface CacheInterface { public function get($key, $default = null);
public function set($key, $value, $ttl = null); public function delete($key); public function clear();
public function getMultiple($keys, $default = null); public function setMultiple($values, $ttl = null); public function deleteMultiple($keys);
public function has($key); }
PSR16
![Page 53: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/53.jpg)
<?php
namespace Psr\SimpleCache;
interface CacheInterface { public function get($key, $default = null);
public function set($key, $value, $ttl = null); public function delete($key); public function clear();
public function getMultiple($keys, $default = null); public function setMultiple($values, $ttl = null); public function deleteMultiple($keys);
public function has($key); }
PSR16
![Page 54: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/54.jpg)
<?php
namespace Psr\SimpleCache;
interface CacheInterface { public function get($key, $default = null);
public function set($key, $value, $ttl = null); public function delete($key); public function clear();
public function getMultiple($keys, $default = null); public function setMultiple($values, $ttl = null); public function deleteMultiple($keys);
public function has($key); }
PSR16
![Page 55: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/55.jpg)
PSR11
![Page 56: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/56.jpg)
Container Interface
aka Container Interop
![Page 57: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/57.jpg)
<?php
namespace Psr\Container;
interface ContainerInterface { public function get($id);
public function has($id); }
PSR11
![Page 58: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/58.jpg)
Dependency Injection
![Page 59: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/59.jpg)
<?php
class Foo { public function __construct() { $handler = new Bar(); $handler->handleInternalStuff($this->value); ... } }
![Page 60: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/60.jpg)
<?php
class Foo { public function __construct() { $handler = new Bar(); $handler->handleInternalStuff($this->value); ... } }
![Page 61: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/61.jpg)
<?php
class Foo { public function __construct() { $handler = new Bar(); $handler->handleInternalStuff($this->value); ... } }
![Page 62: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/62.jpg)
<?php
class Foo { public function __construct() { $handler = new Bar(); $handler->handleInternalStuff($this->value); ... } }
![Page 63: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/63.jpg)
<?php
class Foo { public function __construct() {
$handler->handleInternalStuff($this->value); ... } }
![Page 64: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/64.jpg)
<?php
class Foo { public function __construct( ) {
$handler->handleInternalStuff($this->value); ... } }
![Page 65: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/65.jpg)
<?php
class Foo { public function __construct(Bar $handler) {
$handler->handleInternalStuff($this->value); ... } }
![Page 66: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/66.jpg)
<?php
class Foo { public function __construct(Bar $handler) { $handler->handleInternalStuff($this->value); ... } }
![Page 67: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/67.jpg)
Dependency Injection
• loose coupling
• more flexibility
• easier testing
• better code
• complex object creation
+ -
![Page 68: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/68.jpg)
<?php
$someComplexObject = $container->get('MyComplexObject');
![Page 69: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/69.jpg)
• Disco
• League/Container
• Pimple
• Zend/ServiceManager
PSR11 - Container
![Page 70: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/70.jpg)
• Slim
• zend-expressive
PSR11 - Frameworks
![Page 71: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/71.jpg)
PSR7
![Page 72: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/72.jpg)
HTTP Message
![Page 73: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/73.jpg)
Request
$_GET
$_POST
$_FILES
http_get_request_body()
$_COOKIE
http_get_request_headers()
![Page 74: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/74.jpg)
Response
print()
setcookie()
echo
http_response_code()
header()
http_redirect()
![Page 75: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/75.jpg)
![Page 76: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/76.jpg)
Request
![Page 77: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/77.jpg)
<?php namespace Psr\Http\Message;
interface MessageInterface { public function getProtocolVersion();
public function withProtocolVersion($version);
public function getHeaders();
public function hasHeader($name);
public function getHeader($name);
public function getHeaderLine($name);
public function withHeader($name, $value);
public function withAddedHeader($name, $value);
public function withoutHeader($name);
public function getBody();
public function withBody(StreamInterface $body); }
![Page 78: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/78.jpg)
<?php namespace Psr\Http\Message;
interface RequestInterface extends MessageInterface { public function getRequestTarget();
public function withRequestTarget($requestTarget);
public function getMethod();
public function withMethod($method);
public function getUri();
public function withUri(UriInterface $uri, $preserveHost = false); }
![Page 79: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/79.jpg)
<?php namespace Psr\Http\Message;
interface ServerRequestInterface extends RequestInterface { public function getServerParams();
public function getCookieParams();
public function withCookieParams(array $cookies);
public function getQueryParams();
public function withQueryParams(array $query);
public function getUploadedFiles();
public function withUploadedFiles(array $uploadedFiles);
public function getParsedBody();
public function withParsedBody($data);
public function getAttributes();
public function getAttribute($name, $default = null);
public function withAttribute($name, $value);
public function withoutAttribute($name); }
![Page 80: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/80.jpg)
<?php namespace Psr\Http\Message;
interface MessageInterface { public function getProtocolVersion();
public function withProtocolVersion($version);
public function getHeaders();
public function hasHeader($name);
public function getHeader($name);
public function getHeaderLine($name);
public function withHeader($name, $value);
public function withAddedHeader($name, $value);
public function withoutHeader($name);
public function getBody();
public function withBody(StreamInterface $body); }
![Page 81: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/81.jpg)
<?php namespace Psr\Http\Message;
interface MessageInterface { public function getProtocolVersion();
public function withProtocolVersion($version);
public function getHeaders();
public function hasHeader($name);
public function getHeader($name);
public function getHeaderLine($name);
public function withHeader($name, $value);
public function withAddedHeader($name, $value);
public function withoutHeader($name);
public function getBody();
public function withBody(StreamInterface $body); }
![Page 82: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/82.jpg)
<?php namespace Psr\Http\Message;
interface MessageInterface { public function getProtocolVersion();
public function withProtocolVersion($version);
public function getHeaders();
public function hasHeader($name);
public function getHeader($name);
public function getHeaderLine($name);
public function withHeader($name, $value);
public function withAddedHeader($name, $value);
public function withoutHeader($name);
public function getBody();
public function withBody(StreamInterface $body); }
![Page 83: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/83.jpg)
<?php namespace Psr\Http\Message;
interface RequestInterface extends MessageInterface { public function getRequestTarget();
public function withRequestTarget($requestTarget);
public function getMethod();
public function withMethod($method);
public function getUri();
public function withUri(UriInterface $uri, $preserveHost = false); }
![Page 84: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/84.jpg)
<?php namespace Psr\Http\Message;
interface RequestInterface extends MessageInterface { public function getRequestTarget();
public function withRequestTarget($requestTarget);
public function getMethod();
public function withMethod($method);
public function getUri();
public function withUri(UriInterface $uri, $preserveHost = false); }
![Page 85: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/85.jpg)
<?php namespace Psr\Http\Message;
interface ServerRequestInterface extends RequestInterface { public function getServerParams();
public function getCookieParams();
public function withCookieParams(array $cookies);
public function getQueryParams();
public function withQueryParams(array $query);
public function getUploadedFiles();
public function withUploadedFiles(array $uploadedFiles);
public function getParsedBody();
public function withParsedBody($data);
public function getAttributes();
public function getAttribute($name, $default = null);
public function withAttribute($name, $value);
public function withoutAttribute($name); }
![Page 86: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/86.jpg)
<?php namespace Psr\Http\Message;
interface ServerRequestInterface extends RequestInterface { public function getServerParams();
public function getCookieParams();
public function withCookieParams(array $cookies);
public function getQueryParams();
public function withQueryParams(array $query);
public function getUploadedFiles();
public function withUploadedFiles(array $uploadedFiles);
public function getParsedBody();
public function withParsedBody($data);
public function getAttributes();
public function getAttribute($name, $default = null);
public function withAttribute($name, $value);
public function withoutAttribute($name); }
![Page 87: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/87.jpg)
<?php namespace Psr\Http\Message;
interface ServerRequestInterface extends RequestInterface { public function getServerParams();
public function getCookieParams();
public function withCookieParams(array $cookies);
public function getQueryParams();
public function withQueryParams(array $query);
public function getUploadedFiles();
public function withUploadedFiles(array $uploadedFiles);
public function getParsedBody();
public function withParsedBody($data);
public function getAttributes();
public function getAttribute($name, $default = null);
public function withAttribute($name, $value);
public function withoutAttribute($name); }
![Page 88: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/88.jpg)
<?php namespace Psr\Http\Message;
interface ServerRequestInterface extends RequestInterface { public function getServerParams();
public function getCookieParams();
public function withCookieParams(array $cookies);
public function getQueryParams();
public function withQueryParams(array $query);
public function getUploadedFiles();
public function withUploadedFiles(array $uploadedFiles);
public function getParsedBody();
public function withParsedBody($data);
public function getAttributes();
public function getAttribute($name, $default = null);
public function withAttribute($name, $value);
public function withoutAttribute($name); }
![Page 89: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/89.jpg)
<?php namespace Psr\Http\Message;
interface ServerRequestInterface extends RequestInterface { public function getServerParams();
public function getCookieParams();
public function withCookieParams(array $cookies);
public function getQueryParams();
public function withQueryParams(array $query);
public function getUploadedFiles();
public function withUploadedFiles(array $uploadedFiles);
public function getParsedBody();
public function withParsedBody($data);
public function getAttributes();
public function getAttribute($name, $default = null);
public function withAttribute($name, $value);
public function withoutAttribute($name); }
![Page 90: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/90.jpg)
<?php namespace Psr\Http\Message;
interface ServerRequestInterface extends RequestInterface { public function getServerParams();
public function getCookieParams();
public function withCookieParams(array $cookies);
public function getQueryParams();
public function withQueryParams(array $query);
public function getUploadedFiles();
public function withUploadedFiles(array $uploadedFiles);
public function getParsedBody();
public function withParsedBody($data);
public function getAttributes();
public function getAttribute($name, $default = null);
public function withAttribute($name, $value);
public function withoutAttribute($name); }
![Page 91: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/91.jpg)
[ 'files' => [ 'name' => [ 0 => 'file0.txt', 1 => 'file1.html', ], 'type' => [ 0 => 'text/plain', 1 => 'text/html', ],
...
], ]
![Page 92: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/92.jpg)
[ 'files' => [ 0 => [ 'name' => 'file0.txt', 'type' => ‚text/plain',
...
], 1 => [ 'name' => 'file1.html', 'type' => ‚text/html',
...
], ], ];
![Page 93: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/93.jpg)
[ 'files' => [
0 => /* UploadedFileInterface instance */
1 => /* UploadedFileInterface instance */
] ];
![Page 94: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/94.jpg)
<?php namespace Psr\Http\Message;
interface UploadedFileInterface { public function getStream();
public function moveTo($targetPath);
public function getSize();
public function getError();
public function getClientFilename();
public function getClientMediaType(); }
![Page 95: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/95.jpg)
<?php namespace Psr\Http\Message;
interface UploadedFileInterface { public function getStream();
public function moveTo($targetPath);
public function getSize();
public function getError();
public function getClientFilename();
public function getClientMediaType(); }
![Page 96: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/96.jpg)
<?php namespace Psr\Http\Message;
interface UploadedFileInterface { public function getStream();
public function moveTo($targetPath);
public function getSize();
public function getError();
public function getClientFilename();
public function getClientMediaType(); }
![Page 97: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/97.jpg)
<?php namespace Psr\Http\Message;
interface UploadedFileInterface { public function getStream();
public function moveTo($targetPath);
public function getSize();
public function getError();
public function getClientFilename();
public function getClientMediaType(); }
![Page 98: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/98.jpg)
<?php namespace Psr\Http\Message;
interface UploadedFileInterface { public function getStream();
public function moveTo($targetPath);
public function getSize();
public function getError();
public function getClientFilename();
public function getClientMediaType(); }
![Page 99: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/99.jpg)
<?php namespace Psr\Http\Message;
interface UriInterface { public function getScheme();
public function getAuthority();
public function getUserInfo();
public function getHost();
public function getPort();
public function getPath();
public function getQuery();
public function getFragment();
public function withScheme($scheme);
public function withUserInfo($user, $password = null);
public function withHost($host);
public function withPort($port);
public function withPath($path);
public function withQuery($query);
public function withFragment($fragment);
public function __toString(); }
![Page 100: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/100.jpg)
<?php namespace Psr\Http\Message;
interface UriInterface { public function getScheme();
public function getAuthority();
public function getUserInfo();
public function getHost();
public function getPort();
public function getPath();
public function getQuery();
public function getFragment();
public function withScheme($scheme);
public function withUserInfo($user, $password = null);
public function withHost($host);
public function withPort($port);
public function withPath($path);
public function withQuery($query);
public function withFragment($fragment);
public function __toString(); }
![Page 101: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/101.jpg)
<?php namespace Psr\Http\Message;
interface UriInterface { public function getScheme();
public function getAuthority();
public function getUserInfo();
public function getHost();
public function getPort();
public function getPath();
public function getQuery();
public function getFragment();
public function withScheme($scheme);
public function withUserInfo($user, $password = null);
public function withHost($host);
public function withPort($port);
public function withPath($path);
public function withQuery($query);
public function withFragment($fragment);
public function __toString(); }
![Page 102: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/102.jpg)
<?php namespace Psr\Http\Message;
interface UriInterface { public function getScheme();
public function getAuthority();
public function getUserInfo();
public function getHost();
public function getPort();
public function getPath();
public function getQuery();
public function getFragment();
public function withScheme($scheme);
public function withUserInfo($user, $password = null);
public function withHost($host);
public function withPort($port);
public function withPath($path);
public function withQuery($query);
public function withFragment($fragment);
public function __toString(); }
![Page 103: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/103.jpg)
<?php namespace Psr\Http\Message;
interface UriInterface { public function getScheme();
public function getAuthority();
public function getUserInfo();
public function getHost();
public function getPort();
public function getPath();
public function getQuery();
public function getFragment();
public function withScheme($scheme);
public function withUserInfo($user, $password = null);
public function withHost($host);
public function withPort($port);
public function withPath($path);
public function withQuery($query);
public function withFragment($fragment);
public function __toString(); }
![Page 104: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/104.jpg)
<?php namespace Psr\Http\Message;
interface UriInterface { public function getScheme();
public function getAuthority();
public function getUserInfo();
public function getHost();
public function getPort();
public function getPath();
public function getQuery();
public function getFragment();
public function withScheme($scheme);
public function withUserInfo($user, $password = null);
public function withHost($host);
public function withPort($port);
public function withPath($path);
public function withQuery($query);
public function withFragment($fragment);
public function __toString(); }
![Page 105: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/105.jpg)
Request
• Query data
• POST data
• Cookie data
• Uploaded files
• URI information
• Stream data
![Page 106: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/106.jpg)
Response
![Page 107: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/107.jpg)
<?php namespace Psr\Http\Message;
interface MessageInterface { public function getProtocolVersion();
public function withProtocolVersion($version);
public function getHeaders();
public function hasHeader($name);
public function getHeader($name);
public function getHeaderLine($name);
public function withHeader($name, $value);
public function withAddedHeader($name, $value);
public function withoutHeader($name);
public function getBody();
public function withBody(StreamInterface $body); }
![Page 108: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/108.jpg)
<?php namespace Psr\Http\Message;
interface MessageInterface { public function getProtocolVersion();
public function withProtocolVersion($version);
public function getHeaders();
public function hasHeader($name);
public function getHeader($name);
public function getHeaderLine($name);
public function withHeader($name, $value);
public function withAddedHeader($name, $value);
public function withoutHeader($name);
public function getBody();
public function withBody(StreamInterface $body); }
![Page 109: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/109.jpg)
<?php namespace Psr\Http\Message;
interface ResponseInterface extends MessageInterface { public function getStatusCode();
public function withStatus($code, $reasonPhrase = '');
public function getReasonPhrase(); }
![Page 110: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/110.jpg)
<?php namespace Psr\Http\Message;
interface ResponseInterface extends MessageInterface { public function getStatusCode();
public function withStatus($code, $reasonPhrase = '');
public function getReasonPhrase(); }
![Page 111: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/111.jpg)
<?php namespace Psr\Http\Message;
interface ResponseInterface extends MessageInterface { public function getStatusCode();
public function withStatus($code, $reasonPhrase = '');
public function getReasonPhrase(); }
![Page 112: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/112.jpg)
PSR7
Request
Response
Request
Request
Response
![Page 113: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/113.jpg)
• Slim
• zend-expressive
• Laravel
• Symfony (PSR-7-Bridge)
PSR7 - Frameworks
![Page 114: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/114.jpg)
PSR17 PSR18
![Page 115: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/115.jpg)
PSR17HTTP Factory
![Page 116: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/116.jpg)
<?php
namespace Psr\Http\Message;
![Page 117: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/117.jpg)
<?php
namespace Psr\Http\Message;
interface RequestFactoryInterface
![Page 118: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/118.jpg)
<?php
namespace Psr\Http\Message;
interface RequestFactoryInterface
interface ServerRequestFactoryInterface
![Page 119: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/119.jpg)
<?php
namespace Psr\Http\Message;
interface RequestFactoryInterface
interface ServerRequestFactoryInterface
interface ResponseFactoryInterface
![Page 120: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/120.jpg)
<?php
namespace Psr\Http\Message;
interface RequestFactoryInterface
interface ServerRequestFactoryInterface
interface ResponseFactoryInterface
interface UploadedFileFactoryInterface
![Page 121: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/121.jpg)
<?php
namespace Psr\Http\Message;
interface RequestFactoryInterface
interface ServerRequestFactoryInterface
interface ResponseFactoryInterface
interface UploadedFileFactoryInterface
interface UriFactoryInterface
![Page 122: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/122.jpg)
<?php
namespace Psr\Http\Message;
interface RequestFactoryInterface
interface ServerRequestFactoryInterface
interface ResponseFactoryInterface
interface UploadedFileFactoryInterface
interface UriFactoryInterface
interface StreamFactoryInterface
![Page 123: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/123.jpg)
PSR18HTTP Client
![Page 124: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/124.jpg)
<?php
namespace Psr\Http\Client;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface;
interface ClientInterface { public function sendRequest(RequestInterface $request): ResponseInterface; }
![Page 125: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/125.jpg)
<?php
namespace Psr\Http\Client;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface;
interface ClientInterface { public function sendRequest(RequestInterface $request): ResponseInterface; }
![Page 126: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/126.jpg)
Guzzle
![Page 127: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/127.jpg)
PSR15HTTP Handler
![Page 128: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/128.jpg)
<?php
namespace Psr\Http\Server;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface;
interface RequestHandlerInterface { public function handle(ServerRequestInterface $request): ResponseInterface; }
![Page 129: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/129.jpg)
<?php
namespace Psr\Http\Server;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface;
interface MiddlewareInterface { public function process( ServerRequestInterface $request, RequestHandlerInterface $handler ): ResponseInterface; }
![Page 130: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/130.jpg)
![Page 131: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/131.jpg)
Middleware examples
• Authentication
• Authorization
• Redirecting / Social Routing
• Output Formatting
![Page 132: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/132.jpg)
<?php
use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface;
class FinalResponder implements MiddlewareInterface { public function process( ServerRequestInterface $request, RequestHandlerInterface $handler ): ResponseInterface { try { return $handler->handle($request); } catch (\Exception $e) { return ErrorPage::createResponse($e); } } }
![Page 133: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/133.jpg)
<?php
use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface;
class FinalResponder implements MiddlewareInterface { public function process( ServerRequestInterface $request, RequestHandlerInterface $handler ): ResponseInterface { try { return $handler->handle($request); } catch (\Exception $e) { return ErrorPage::createResponse($e); } } }
![Page 134: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/134.jpg)
<?php
use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface;
class FinalResponder implements MiddlewareInterface { public function process( ServerRequestInterface $request, RequestHandlerInterface $handler ): ResponseInterface { try { return $handler->handle($request); } catch (\Exception $e) { return ErrorPage::createResponse($e); } } }
![Page 135: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/135.jpg)
<?php
use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface;
class FinalResponder implements MiddlewareInterface { public function process( ServerRequestInterface $request, RequestHandlerInterface $handler ): ResponseInterface { try { return $handler->handle($request); } catch (\Exception $e) { return ErrorPage::createResponse($e); } } }
![Page 136: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/136.jpg)
<?php
use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface;
class FinalResponder implements MiddlewareInterface { public function process( ServerRequestInterface $request, RequestHandlerInterface $handler ): ResponseInterface { try { return $handler->handle($request); } catch (\Exception $e) { return ErrorPage::createResponse($e); } } }
![Page 137: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/137.jpg)
• Single Responsibility
• Tiny testable peaces
• Defined data flow
PSR15 - Middleware
![Page 138: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/138.jpg)
PSR14
![Page 139: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/139.jpg)
Event ManagerDRAFT
![Page 140: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/140.jpg)
• Events
• Tasks
• Emitter
• EventLister
• Processor
PSR14
![Page 141: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/141.jpg)
• Security framework that handles access permissions
• Common full page caching system
• Logging package to track all actions
PSR14
![Page 142: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/142.jpg)
PSR8
![Page 143: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/143.jpg)
Huggable Interface
![Page 144: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/144.jpg)
<?php namespace Psr\Hug;
/** * Defines a huggable object. * * A huggable object expresses mutual affection with another huggable object. */ interface Huggable {
/** * Hugs this object. * * All hugs are mutual. An object that is hugged MUST in turn hug the other * object back by calling hug() on the first parameter. All objects MUST * implement a mechanism to prevent an infinite loop of hugging. * * @param Huggable $h * The object that is hugging this object. */ public function hug(Huggable $h); }
![Page 145: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/145.jpg)
![Page 146: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/146.jpg)
💩
PSR8
PSR15 PSR7
PSR18
PSR2
PSR6
PSR8PSR12
PSR4
PSR11
![Page 147: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/147.jpg)
Deadpool loves standards
![Page 148: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/148.jpg)
![Page 149: STANDARDS A PHP DEVELOPER SHOULD KNOWsebastian-feldmann.info/talks/2018/20181016-10-standards-a-php... · STANDARDS A PHP DEVELOPER SHOULD KNOW sebastianfeldmann @movetodevnull Sebastian](https://reader034.vdocuments.mx/reader034/viewer/2022043009/5f9d1bd5b68886579f71f7c8/html5/thumbnails/149.jpg)
Sebastian Feldmann
@movetodevnull
https://phpbu.de
sebastianfeldmann
Captain Hook