Interview frequency: …
Short answer
It is a modern web server built with Go (Caddy) and an embedded PHP runtime; Worker Mode keeps the application loaded in memory between requests, reducing per-request startup cost and greatly increasing throughput (depending on the application).
Explanation
The traditional PHP model follows 'Share Nothing': the environment is built and completely cleared for every HTTP request. FrankenPHP's Worker Mode starts the framework (such as Laravel), loads packages and database connections once, and then serves thousands of requests without rebuilding the environment, achieving response times in the single-digit milliseconds.
Code example
# Caddyfile — enable worker mode
{
frankenphp {
worker ./public/index.php
}
}
<?php
// public/index.php — the app boots ONCE and then serves many requests from memory
ignore_user_abort(true);
require __DIR__ . '/../vendor/autoload.php';
$app = require __DIR__ . '/../bootstrap/app.php';
$handler = static function () use ($app) {
// handle ONE request with the already-booted application
};
while (frankenphp_handle_request($handler)) {
gc_collect_cycles(); // clean up between requests; avoid leaking state across them
}Common mistakes
- Storing user state in static variables in Worker Mode, which can leak data between users' requests.