Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHPのmiddlewareを 使いこなすために

PHPのmiddlewareを 使いこなすために

PHPカンファレンス仙台2019での発表資料です。
https://phpcon-sendai.net/2019/

YAMAOKA Hiroyuki

January 26, 2019
Tweet

More Decks by YAMAOKA Hiroyuki

Other Decks in Technology

Transcript

  1. 1)1Ͱॻ͍ͯΈΔͱ $a = function (string $str, \Closure $next) : string

    { echo 'A'; // લॲཧΆ͍
 $result = $next($str); // ࣍ΛݺͿ echo 'C'; // ޙॲཧΆ͍ return $result; };
 $b = function (string $str) : string { echo 'B';
 return strtoupper($str); };
 $a('hoge', $b); // ABC
  2. 4MJN  class ExampleMiddleware { public function __invoke( ServerRequestInterface $request,

    ResponseInterface $response, callable $next ): ResponseInterface { return $next($request, $response); } }
  3. $BLF1)1  class ExampleMiddleware { public function handle( ServerRequestInterface $request,

    ResponseInterface $response, callable $next ): \Cake\Http\Response { return $next($request, $response); } }