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

Symfony Runtime - A First Look

Symfony Runtime - A First Look

For the upcoming Symfony 5.3 release a new experimental component is announced: Symfony Runtime. In this talk we will look at what the runtime component is for, how it is used in a typical Symfony app running via php-fpm/php-cli and how you can adapt it for alternative runtimes like ReactPHP.

6a1345d8e6dd15b2c78eff0c331963b1?s=128

Denis Brumann

April 06, 2021
Tweet

Transcript

  1. Denis Brumann ⠇Symfony User Group Hamburg ⠇2021-04-06 Symfony Runtime A

    First Look
  2. 2 Denis Brumann denis.brumann@qossmic.com @dbrumann

  3. 3 What is a runtime?

  4. Symfony Runtime - A First Look ⠇@dbrumann 4 What is

    a runtime?
  5. Symfony Runtime - A First Look ⠇@dbrumann 5 What is

    a runtime?
  6. Symfony Runtime - A First Look ⠇@dbrumann 6 What is

    a runtime?
  7. Symfony Runtime - A First Look ⠇@dbrumann 7 What is

    a runtime?
  8. Symfony Runtime - A First Look ⠇@dbrumann 7 What is

    a runtime?
  9. Symfony Runtime - A First Look ⠇@dbrumann 8 What is

    a runtime?
  10. Symfony Runtime - A First Look ⠇@dbrumann 8 What is

    a runtime? When using Apache, you can con gure PHP as an Apache module or FastCGI using PHP FPM. FastCGI also is the preferred way to use PHP with Nginx.
  11. Symfony Runtime - A First Look ⠇@dbrumann 9 What is

    a runtime?
  12. Symfony Runtime - A First Look ⠇@dbrumann 9 What is

    a runtime?
  13. Symfony Runtime - A First Look ⠇@dbrumann 10 What is

    a runtime?
  14. Symfony Runtime - A First Look ⠇@dbrumann 10 What is

    a runtime?
  15. Symfony Runtime - A First Look ⠇@dbrumann 11 What is

    a runtime?
  16. Symfony Runtime - A First Look ⠇@dbrumann 11 What is

    a runtime?
  17. Symfony Runtime - A First Look ⠇@dbrumann 12 What is

    a runtime?
  18. Symfony Runtime - A First Look ⠇@dbrumann 12 What is

    a runtime?
  19. 13 Bootstrapping Symfony

  20. Symfony Runtime - A First Look ⠇@dbrumann 15 Bootstrapping Symfony

  21. Symfony Runtime - A First Look ⠇@dbrumann 16 Bootstrapping Symfony

  22. Symfony Runtime - A First Look ⠇@dbrumann 17 Bootstrapping Symfony

  23. Symfony Runtime - A First Look ⠇@dbrumann 18 Bootstrapping Symfony

  24. Symfony Runtime - A First Look ⠇@dbrumann 19 Bootstrapping Symfony

  25. 20 Sidenote: Experimental Features

  26. Symfony Runtime - A First Look ⠇@dbrumann 21 Sidenote: Experimental

    Features
  27. 22 The Runtime Component

  28. Symfony Runtime - A First Look ⠇@dbrumann 23 The Runtime

    Component The Runtime Component decouples the bootstrapping logic from any global state to make sure the application can run with runtimes like PHP-FPM. ReactPHP, Swoole, etc. without any changes.
  29. Symfony Runtime - A First Look ⠇@dbrumann 24 The Runtime

    Component
  30. Symfony Runtime - A First Look ⠇@dbrumann 24 The Runtime

    Component
  31. Symfony Runtime - A First Look ⠇@dbrumann 25 The Runtime

    Component
  32. Symfony Runtime - A First Look ⠇@dbrumann 25 The Runtime

    Component
  33. Symfony Runtime - A First Look ⠇@dbrumann 25 The Runtime

    Component
  34. Symfony Runtime - A First Look ⠇@dbrumann 26 The Runtime

    Component interface RuntimeInterface { /** * Returns a resolver that should compute the arguments of a callable. * * The callable itself should return an object that represents the application to pass to the getRunner() method. */ public function getResolver(callable $callable, \ReflectionFunction $reflector = null): ResolverInterface; /** * Returns a callable that knows how to run the passed object and that returns its exit status as int. * * The passed object is typically created by calling ResolverInterface::resolve(). */ public function getRunner(?object $application): RunnerInterface; }
  35. Symfony Runtime - A First Look ⠇@dbrumann 27 The Runtime

    Component [$app, $args] = $runtime ->getResolver($app) ->resolve(); $app = $app(...$args); exit( $runtime ->getRunner($app) ->run() );
  36. Symfony Runtime - A First Look ⠇@dbrumann 27 The Runtime

    Component [$app, $args] = $runtime ->getResolver($app) ->resolve(); $app = $app(...$args); exit( $runtime ->getRunner($app) ->run() ); return function (array $context) { return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); }
  37. Symfony Runtime - A First Look ⠇@dbrumann 28 The Runtime

    Component
  38. 29 Custom Runtimes

  39. Symfony Runtime - A First Look ⠇@dbrumann 30 Custom Runtimes

  40. Symfony Runtime - A First Look ⠇@dbrumann 31 Custom Runtimes

  41. Symfony Runtime - A First Look ⠇@dbrumann 32 Custom Runtimes

  42. Symfony Runtime - A First Look ⠇@dbrumann 33 Custom Runtimes

  43. 34 Questions