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. Denis Brumann ⠇Symfony User Group Hamburg ⠇2021-04-06
    Symfony Runtime
    A First Look

    View Slide

  2. 2
    Denis Brumann
    [email protected]
    @dbrumann

    View Slide

  3. 3
    What is a runtime?

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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.

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  19. 13
    Bootstrapping Symfony

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  25. 20
    Sidenote: Experimental Features

    View Slide

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

    View Slide

  27. 22
    The Runtime Component

    View Slide

  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.

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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;
    }

    View Slide

  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()
    );

    View Slide

  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']);
    }

    View Slide

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

    View Slide

  38. 29
    Custom Runtimes

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  43. 34
    Questions

    View Slide