Slide 1

Slide 1 text


Slide 2

Slide 2 text

The New PHP Era 01 02 03 04 The State of PHP API Platform 3.2 What’s Next

Slide 3

Slide 3 text

About Me ✔ API Platform creator ✔ co-founder ✔ Polyglot developer Kévin Dunglas [email protected] @dunglas

Slide 4

Slide 4 text

The State of PHP A bit dated

Slide 5

Slide 5 text


Slide 6

Slide 6 text

Deploying PHP Apps ✖ PHP doesn’t speak HTTP directly ✖ PHP must be bridged with a web server ✖ PHP-FPM is the most popular Server API (SAPI) - External server using the FastCGI protocol ✖ Alternative: mod_php for Apache: - Not compatible or not recommended with modern Apache

Slide 7

Slide 7 text

Deploying PHP Apps: Summary ✖ Unlike alternatives (e.g. Node), PHP has no built-in HTTP server ✖ PHP-FPM needs a 3rd-party web server ✖ This implies: ○ At least 2 services ○ A shared file (UNIX socket, best option) or a network link between the FPM and the web server

Slide 8

Slide 8 text

PHP Apps: Onboarding Local installation is complex, all users need: ✖ PHP-FPM ✖ A web server ✖ Same versions on every machine, and in prod ✖ Same configuration on every machine, and in prod ✖ Fortunately, Docker helps: API Platform distribution, Symfony Docker, Laravel Sail… NEW DEVS NOT WELCOME

Slide 9

Slide 9 text

PHP Apps: Docker / Kubernetes © sergioska

Slide 10

Slide 10 text

PHP Performance ✔ The language itself is now very fast (faster than Python or Ruby) ✖ But PHP is “fire and forget” ✖ Everything that is built to handle a request is then destroyed when the request is handled: - Symfony kernel - Symfony DIC - Services - In memory caches…

Slide 11

Slide 11 text

PHP Real-time ✖ PHP isn’t designed to support long-running connections (max_execution_time, no direct access to the network layer…) ✖ WebSocket, SSE, WebTransport and the like are not (or badly) supported by typical PHP setups ✖ It’s the same for other advanced/modern HTTP features (e.g. 103 Early Hints)

Slide 12

Slide 12 text

The New PHP Era The Modern Prometheus

Slide 13

Slide 13 text

Introducing FrankenPHP 1.0 beta

Slide 14

Slide 14 text

The Modern PHP App Server ✔ All in one HTTP server with native, vanilla, PHP support ✔ Cloud Native ✔ Built with Docker in mind… ✔ …but also available as a standalone static binary ✔ Worker mode ✔ Native Mercure support ✔ Early Hints and much more!

Slide 15

Slide 15 text

Web Browser PHP Threads Only One Service HTTP REQUEST HTTP RESPONSE

Slide 16

Slide 16 text

Moderner PHP Than Ever ✔ The official PHP executor is embedded in a state-of-the-art web server: Caddy ✔ Native support for HTTP 1, 2 and 3 ✔ Automatic HTTPS certificates generation and renewal (Let’s Encrypt or ZeroSSL) ✔ Copy your PHP files in the document root, that’s all! ✔ Popular PHP extensions, including OPcache and XDebug, are natively supported!

Slide 17

Slide 17 text

Docker Images $ docker run .:/app/public dunglas/frankenphp ✔ Exposes the current directory (as php -S) ✔ Built on top of official PHP Images ✔ PHP 8.2 and 8.3 variants ✔ Install PHP extensions as usual ✔ An Alpine variant exists (default: Debian)

Slide 18

Slide 18 text

One Binary To Rule Them All

Slide 19

Slide 19 text

One Binary To Rule Them All $ ./frankenphp run --config /my/Caddyfile ✔ Exposes the current directory (as php -S) ✔ Static binary (no dependencies) ✔ Caddy, FrankenPHP, PHP and all popular PHP extensions are embedded ✔ Available for macOS and Linux

Slide 20

Slide 20 text

Worker Mode ✔ Boot your application once and keep it in memory! ✔ Process incoming requests without having to boot your app again ✔ Compatible with API Platform and Symfony thanks to Symfony Runtime ✔ Written in C and Go (awesome concurrency engine) ✔ According to our benchmarks, 3.5x faster than FPM with API Platform ✔ Unlike alternatives (RoadRunner, Swoole…) ○ entirely optional: typical apps still work with FrankenPHP ○ runs in process: no network calls ○ uses plain old superglobals: no need for PSR-7 etc

Slide 21

Slide 21 text

Worker Mode

Slide 22

Slide 22 text

Real-time: Built-in Mercure Hub

Slide 23

Slide 23 text

103 Early Hints

Slide 24

Slide 24 text

Already Popular

Slide 25

Slide 25 text

❤ Free Software

Slide 26

Slide 26 text

FrankenPHP and API Platform Best Friends Forever

Slide 27

Slide 27 text

API Platform 3.2 Beta Is Out! $ gh repo create my-project \ --clone --private \ --template api-platform/api-platform $ cd my-project $ docker compose up --wait

Slide 28

Slide 28 text

3.2 Includes FrankenPHP ✔ Key feature: FrankenPHP is now part of the API Platform distribution ✔ Prod mode (Kubernetes, Docker Compose…) uses FrankenPHP workers ✔ The distribution has been dramatically simplified: only 1 core service for PHP ✔ You don’t have to change a single line of code! ✔ An FPM variant is still provided (for now)

Slide 29

Slide 29 text

Other Docker Improvements ✔ 6x times faster builds ✔ Cached layers reused across builds when using GitHub Actions ✔ Simplified and improved Dockerfiles ✔ Symfony Docker also benefits from FrankenPHP and these improvements

Slide 30

Slide 30 text


Slide 31

Slide 31 text

Now: 7x Faster

Slide 32

Slide 32 text

Native OAuth and OIDC support

Slide 33

Slide 33 text

Groundbreaking WASM-based runnable documentation

Slide 34

Slide 34 text

Improved DTO system

Slide 35

Slide 35 text

Better Extensibility And Dozens of Other Improvements

Slide 36

Slide 36 text

What’s Next Still Some Work To Do

Slide 37

Slide 37 text

Known Issues With FrankenPHP ✖ Fibers aren’t reliable (work in progress, in the Go runtime) ✖ Crashes when building the Symfony cache with the Alpine Variant (use Debian for now) ✖ Doctrine isn’t 100% reliable in worker mode (work in progress)

Slide 38

Slide 38 text

Going One Step Further

Slide 39

Slide 39 text

FOLLOW ME! @dunglas / / Thank you! Any questions?