Slide 1

Slide 1 text

A modern app server for PHP and Symfony https://frankenphp.dev

Slide 2

Slide 2 text

➔ PHP API Platform creator, Symfony maintainer ➔ GO Go core contributor, Mercure.rocks and Vulcain.rocks creator ➔ C PHP core contributor Kévin Dunglas: Polyglot Dev @dunglas

Slide 3

Slide 3 text

Web and Cloud Experts ➔ 100% employee-owned co-op ✊ ➔ Democratically managed 💬 ➔ 70 people 🦄 ➔ Distributed company 🌎 ➔ [email protected] 💌

Slide 4

Slide 4 text

FrankenPHP A modern app server for PHP and Symfony ➔ Built for containers ➔ Worker mode ➔ 103 Early Hints support ➔ Real-time support (Mercure module) ➔ Compatible with all existing PHP apps: progressive enhancement

Slide 5

Slide 5 text

Symfony and Containers

Slide 6

Slide 6 text

Containers: Which SAPI? Server Application Programming Interface: interface between the PHP interpreter and web servers ➔ Apache module ➔ FPM (FastCGI Process Manager) ➔ CGI (Common Gateway Interface) ➔ NGINX Unit (not the NGINX you’re used to) ➔ …

Slide 7

Slide 7 text

➔ Simple ➔ Web server + PHP = 1 service ➔ Default solution for containers DRAWBACKS: ➔ Works only with Apache ➔ Less performant than FPM Apache Module

Slide 8

Slide 8 text

FPM ➔ Most popular SAPI ➔ Supported by most web servers: Caddy, NGINX, Apache… DRAWBACKS: ➔ External service ➔ Require a UNIX or a TCP socket ➔ Hard to containerize

Slide 9

Slide 9 text

© sergioska FPM and containers

Slide 10

Slide 10 text

Can We Do Better?!

Slide 11

Slide 11 text

➔ Perfect for containers ◆ Just 1 service ◆ No external dependencies ◆ Batteries included ➔ Contains the Caddy web server ◆ All Caddy features and modules ◆ Benefits from Go features ◆ Extensible: in Go, in C, in PHP ➔ Prod, CI and dev FrankenPHP: Modern PHP App Server

Slide 12

Slide 12 text

➔ Standalone Go library ➔ Embed PHP in your Go programs ➔ New SAPI for Go net/http ◆ Caddy, Symfony CLI, Traefik, K8S… ◆ Your custom Go app ➔ Caddy module using the library ➔ Unique features The ❤ of FrankenPHP: A New SAPI For Go

Slide 13

Slide 13 text

➔ Easy to configure ➔ Cloud native: API, hot config reloading… ➔ Automatic HTTPS ➔ HTTP/2, HTTP/3, Early Hints… ➔ Extensible with modules: Mercure, Vulcain, OAuth, OIDC… ➔ Prod ready ➔ Server of Symfony Docker ➔ Written in Go 😻: secure and fast Caddy: The New Kid on the Block

Slide 14

Slide 14 text

➔ Compatible with existing PHP apps! ➔ 1 service, 1 minimal Docker image 😍 ➔ Also works without Docker ➔ Entirely configurable ◆ Caddyfile ◆ php.ini ➔ Free software (as in free speech ✊, and free beer 🍺) FrankenPHP: At a Glance

Slide 15

Slide 15 text

Getting Started

Slide 16

Slide 16 text

Getting Started

Slide 17

Slide 17 text

Alternative: Symfony CLI ➔ Simple local web server ➔ Built-in TLS support ➔ Dev environments only ➔ Auto-detects and auto-configures: ● PHP FPM and CLI ● Docker Compose services: Postgres, MySQL, Mailcatcher, Redis, RabbitMQ… ➔ Works with any PHP app (even if not using SF) ➔ Written in Go 😻 @dunglas

Slide 18

Slide 18 text

🧪 Symfony CLI X FrankenPHP

Slide 19

Slide 19 text

FrankenPHP Superpower: The Worker Mode ➔ Boot your application once ➔ Keep it in memory ➔ Process incoming requests without having to boot your app again ➔ Relies on goroutines and channels ➔ Compatible with Symfony Runtime ➔ Somewhat similar to RoadRunner ➔ Unlike RoadRunner ◆ runs in process: no network calls, no gRPC ◆ uses plain old superglobals: no PSR-7

Slide 20

Slide 20 text

Worker Script

Slide 21

Slide 21 text

Starting the Worker Mode By default, one worker per CPU is started.

Slide 22

Slide 22 text

The Runtime Component

Slide 23

Slide 23 text

Symfony App in Worker Mode

Slide 24

Slide 24 text

FrankenPHP: Worker Benchmark 🧪 ➔ Setup: ◆ Hello World Symfony app (prod mode) ◆ Caddy Web Server (HTTP/2) ◆ 3000 requests, 100 connected users ◆ Benchmark tool: K6 ➔ Average request duration: ◆ FPM: 9.45ms ◆ FrankenPHP (worker): 2.53ms ➔ Take it with a grain of salt, run your own!

Slide 25

Slide 25 text

103 Early Hints

Slide 26

Slide 26 text

Typical Web Page © Google

Slide 27

Slide 27 text

103 Early Hints © Google

Slide 28

Slide 28 text

Early Hints: Not Possible With PHP

Slide 29

Slide 29 text

Early Hints: Possible With Go 👋

Slide 30

Slide 30 text

Early Hints: Supported by FrankenPHP ⚡

Slide 31

Slide 31 text

Early Hints: Symfony 6.3 ⚡

Slide 32

Slide 32 text

Real-time

Slide 33

Slide 33 text

FrankenPHP includes a Mercure hub!

Slide 34

Slide 34 text

➔ Symfony (worker mode) ➔ API Platform (worker mode) ➔ Sulu (worker mode) ➔ Drupal ➔ Shopware ➔ WordPress ➔ All tested PHP extensions, including opcache and parallel Projects Known to Work With FrankenPHP

Slide 35

Slide 35 text

➔ Test, test and test again ➔ Release a stable version when PHP 8.2 will be out ➔ 🚧 Add Windows support ➔ Add a built-in distributed HTTP cache server ➔ Add a built-in distributed cache system (like Memcache) ➔ Conquer the (PHP) world ➔ Contributions welcome! What’s next?!

Slide 36

Slide 36 text

Try it, give it a star on GitHub... … and win Laury’s merch at our booth! Thanks! frankenphp.dev @dunglas