Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

The PHP Revolution Is Underway: FrankenPHP 1.0 ...

The PHP Revolution Is Underway: FrankenPHP 1.0 Beta

I'm very proud to announce the immediate availability of FrankenPHP 1.0 beta.

FrankenPHP is a brand-new application server for PHP, written in Go and built on top of Caddy, that dramatically simplifies the deployment of PHP apps, and brings new features to PHP such as:

- a worker mode that improves typical application performance by a factor of 3
- native support for HTTP/3
- native support for the 103 Early Hints HTTP status code (assets preloading)
- automatic HTTPS certificate generation and renewal
- native support for the Mercure protocol (real-time data broadcasting)
- and much more!

FrankenPHP is available as a Docker image (Debian, Alpine, PHP 8.2, and PHP 8.3 variants are available) and as standalone binaries with 0 dependencies for Linux and macOS.

Kévin Dunglas

September 21, 2023
Tweet

More Decks by Kévin Dunglas

Other Decks in Programming

Transcript

  1. The New PHP Era 01 02 03 04 The State

    of PHP API Platform 3.2 What’s Next
  2. PHP FPM Web Browser Web Server (NGINX, Caddy, …) HTTP

    REQUEST HTTP RESPONSE PHP-FPM PHP processes FASTCGI REQUEST FASTCGI RESPONSE
  3. 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
  4. 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
  5. 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
  6. 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…
  7. 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)
  8. 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!
  9. 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!
  10. 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)
  11. 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
  12. 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
  13. 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
  14. 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)
  15. 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
  16. 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)