psr-7-packages

 psr-7-packages

A talk about packages that use the common request/response interfaces of PSR-7. They showcase the force of interoperable interfaces.

Demo code for this talk can be found here: https://github.com/hannesvdvreken/psr7-demo

Presented at php.gent for the first time on June 30th 2015.

39eb3f3d313b13f05534e496285040b8?s=128

Hannes Van De Vreken

June 30, 2015
Tweet

Transcript

  1. 5.
  2. 12.
  3. 32.

    GUZZLEHTTP/GUZZLE - MIDDLEWARES $stack = HandlerStack::create(); $client = new Client(['handler'

    => $stack]); $stack->push($middleware); $stack->unshift($middleware);
  4. 33.

    GUZZLEHTTP/GUZZLE - MIDDLEWARES $middleware = function ($handler) { return function

    ($request, $options) use ($handler) { // Do before return $handler($request, $options) ->then(function () { // Do after }); }; }
  5. 45.

    GUZZLEHTTP/GUZZLE - PROGRESS $response = $client->get($uri); // Psr\Http\Message\StreamInterface $stream =

    $response->getBody(); $stream->getSize(); $stream->eof(); $stream->read(1024);
  6. 49.
  7. 53.
  8. 55.

    PHP-HTTP/ADAPTER - SOLUTION public function __construct( Http\Adapter\HttpAdapter $adapter ) {

    $this->adapter = $adapter; } public function __construct( Http\Client\HttpClient $client ) { $this->client = $client; }
  9. 58.
  10. 62.

    PHP-HTTP/ADAPTER - COMPOSER.JSON "require": { - "guzzlehttp/guzzle": "^5.0", + "guzzlehttp/guzzle":

    "^6.0", "your-awesome/sdk": "^1.0",
 - "php-http/guzzle5-adapter": "^0.1.0" + "php-http/guzzle6-adapter": "^0.1.0" }
  11. 63.
  12. 68.

    • http:/ /mwl.be • https:/ /github.com/guzzle/guzzle • https:/ /github.com/php-http •

    http:/ /docs.guzzlephp.org/en/latest/ • https:/ /github.com/php-fig/http-message • https:/ /github.com/php-fig/fig-standards/
 blob/master/accepted/PSR-7-http-message.md REFERENCES