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

実はLaravelで使われている!?Symfonyコンポーネントを紹介!

 実はLaravelで使われている!?Symfonyコンポーネントを紹介!

kunihiko kitamura

September 16, 2023
Tweet

More Decks by kunihiko kitamura

Other Decks in Technology

Transcript

  1. 自己紹介 北 村 邦 彦 ・株式会社カルテットコミュニケーションズ ・前職: 営業職 → 現職:

    バックエンドエンジニア (PHP+Symfony) Twitter:@kuni__94 GitHub:@kitamurakunihiko キタムラ クニヒコ
  2. class Router implements BindingRegistrar, RegistrarContract { … public function dispatchToRoute(Request

    $request) { return $this->runRoute($request, $this->findRoute($request)); } … } Illuminate∖Routing∖Router.php
  3. class Router implements BindingRegistrar, RegistrarContract { … public function dispatchToRoute(Request

    $request) { return $this->runRoute($request, $this->findRoute($request)); } … } Illuminate∖Routing∖Router.php
  4. class Router implements BindingRegistrar, RegistrarContract { … public function dispatchToRoute(Request

    $request) { return $this->runRoute($request, $this->findRoute($request)); } … } Illuminate∖Routing∖Router.php
  5. use Symfony∖Component∖HttpFoundation∖Request as SymfonyRequest; class Request extends SymfonyRequest implements Arrayable,

    ArrayAccess { use Concerns∖CanBePrecognitive, Concerns∖InteractsWithContentTypes, … ; protected $json; … } Illuminate∖Http∖Request
  6. Symfony∖Component∖HttpFoundation∖Request class_exists(AcceptHeader::class); class Request { public const HEADER_FORWARDED = 0b000001;

    // When using RFC 7239 public const HEADER_X_FORWARDED_FOR = 0b000010; ... protected static $trustedProxies = []; protected static $trustedHostPatterns = []; ... }
  7. use Symfony∖Component∖HttpFoundation∖Request as SymfonyRequest; class Request extends SymfonyRequest implements Arrayable,

    ArrayAccess { use Concerns∖CanBePrecognitive, Concerns∖InteractsWithContentTypes, … ; protected $json; … } Illuminate∖Http∖Request
  8. use Symfony∖Component∖VarDumper∖VarDumper; function dump(mixed ...$vars): mixed { ... if (array_key_exists(0,

    $vars) && 1 === count($vars)) { VarDumper::dump($vars[0]); $k = 0; } else { foreach ($vars as $k => $v) { VarDumper::dump($v, is_int($k) ? 1 + $k : $k); } } ... return $vars[$k]; } symfony∖var-dumper∖Resources∖functions
  9. class VarDumper { private static $handler; public static function dump(mixed

    $var/* , string $label = null */) { $label = 2 <= ¥func_num_args() ? func_get_arg(1) : null; if (null === self::$handler) { self::register(); } return (self::$handler)($var, $label); } } symfony∖var-dumper∖Resources∖functions