$30 off During Our Annual Pro Sale. View Details »

FrankenPHP: a modern app server for PHP and Sym...

FrankenPHP: a modern app server for PHP and Symfony apps

FrankenPHP is a modern application server for PHP built in Go. FrankenPHP gives superpowers to your PHP apps: Early Hints, worker mode, real-time capabilities, automatic HTTPS, HTTP/2, and HTTP/3 support...

How does Symfony fit with FrankenPHP? What benefits does it bring to the Symfony ecosystem?

Symfony Runtime, Symfony HttpFoundation, Symfony Mercure, Symfony Local Web Server... let's see how the Symfony ecosystem can leverage FrankenPHP for the sake of performance and simplicity!

This is a variant of: https://dunglas.dev/2022/10/frankenphp-the-modern-php-app-server-written-in-go/

Kévin Dunglas

November 17, 2022
Tweet

More Decks by Kévin Dunglas

Other Decks in Programming

Transcript

  1. ➔ 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
  2. Web and Cloud Experts ➔ 100% employee-owned co-op ✊ ➔

    Democratically managed 💬 ➔ 70 people 🦄 ➔ Distributed company 🌎 ➔ [email protected] 💌
  3. 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
  4. 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) ➔ …
  5. ➔ Simple ➔ Web server + PHP = 1 service

    ➔ Default solution for containers DRAWBACKS: ➔ Works only with Apache ➔ Less performant than FPM Apache Module
  6. 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
  7. ➔ 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
  8. ➔ 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
  9. ➔ 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
  10. ➔ 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
  11. 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
  12. 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
  13. 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!
  14. ➔ 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
  15. ➔ 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?!
  16. Try it, give it a star on GitHub... … and

    win Laury’s merch at our booth! Thanks! frankenphp.dev @dunglas