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.

Denis Brumann

April 06, 2021
Tweet

More Decks by Denis Brumann

Other Decks in Programming

Transcript

  1. 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.
  2. 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.
  3. 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; }
  4. Symfony Runtime - A First Look ⠇@dbrumann 27 The Runtime

    Component [$app, $args] = $runtime ->getResolver($app) ->resolve(); $app = $app(...$args); exit( $runtime ->getRunner($app) ->run() );
  5. 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']); }