A new app server and a library to embed PHP in Go.
* Easy to Dockerize
* Early Hints Support
* Worker mode for performance
* Real-time with the built-in Mercure hub
* Symfony integration (Laravel coming soon)
containers ➔ Worker mode ➔ 103 Early Hints support ➔ Real-time support (Mercure module) ➔ Compatible with all existing PHP apps: ◆ progressive enhancement
PHP interpreter and web servers ➔ Apache module ➔ FPM (FastCGI Process Manager) ➔ CGI (Common Gateway Interface) ➔ NGINX Unit (not the NGINX you’re used to) ➔ …
native: API, hot config reloading… ➔ Automatic HTTPS ➔ HTTP/2, HTTP/3, Early Hints… ➔ Extensible with modules: Mercure, Vulcain, OAuth, OIDC… ➔ Prod ready ➔ Written in Go 😻 Caddy: The New Kid on the Block
external dependencies ➔ Built on top of Caddy ◆ 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
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
container image 😍 ➔ Also works without Docker ➔ Entirely configurable ◆ Caddyfile ◆ php.ini ➔ Free software (as in free speech ✊, and free beer 🍺) FrankenPHP: At a Glance
➔ Keep it in memory ➔ Process incoming requests without having to boot your app again ➔ Relies on goroutines and channels ➔ Compatible with Symfony Runtime and Laravel Octane (soon) ➔ Somewhat similar to RoadRunner ➔ Unlike RR, uses plain old superglobals
written in C ➔ php-src uses Zend Engine ◆ compiler (with Just In Time) ◆ executor (Virtual Machine) ➔ SAPIs ◆ Pass input from the web server to the PHP engine ◆ Pass output from the the PHP engine to the web server PHP Internals: the Basics
by C programs as a library ◆ It’s how the Apache module works ➔ The embed SAPI eases the process for simple cases ➔ The library can be linked ◆ dynamically (.so) ◆ statically
call C code ➔ Go and C files can be compiled in a single program ➔ The resulting binary can be static! ➔ The native package to call C code is called cgo ➔ Using cgo we can embed PHP in Caddy, Symfony CLI and other Go programs! C? Go? Cgo!
apps ➔ net/http: native package to create HTTP clients and servers ➔ Production-grade: optimized and secure ➔ Native HTTP/2 (HTTP/3 with a 3rd party lib) ➔ Used by Caddy, Symfony CLI, Kubernetes, Traefik, Google, Cloudflare… net/http
a server and the PHP engine ➔ Use cgo to call PHP with data coming from Go’s HTTP messages ➔ Extract data from Go’s http.Request, pass it to PHP ➔ Write data generated by PHP using Go’s http.ResponseWriter
goroutines ➔ Goroutines are lightweight threads ➔ Goroutines are executed concurrently ➔ Goroutines can run in parallel on different CPUs ➔ Go provides user-friendly synchronization mechanisms (channels) Goroutines
(system threads) and asynchronous I/O ➔ Several goroutines share the same OS thread ➔ Goroutines are lighter and faster than OS threads… ➔ …but ZTS isn’t enough to ensure PHP memory safety 😱 PHP must run in its own threads! Goroutines Aren’t OS Threads
issues ➔ Test, test and test again ➔ Add support to Laravel Octane ➔ Use it in Symfony CLI ➔ Add Windows support ➔ Contributions welcome! What’s next?!