0016: Laravel Octane as a site's server
On this page
Status: accepted
Context
Laravel apps deployed on Octane behave differently from PHP-FPM: the app boots once and stays in memory, so state can leak between requests. Before this, Short Leash could run octane:start only as a background process while .test still went to PHP-FPM, so nothing exercised Octane in development. Octane needs a server binary. Swoole is a PHP extension, and FrankenPHP is a standalone program with PHP built in.
Decision
- A site's
octanesetting (swooleorfrankenphp) turns a Laravel site into an app server. Short Leash runsphp artisan octane:start --server=<server> --host=127.0.0.1 --port=$PORTand proxies the site to that port, the way it does for command sites.- FrankenPHP also gets
--admin-port=$ADMIN_PORT, a second free port, so several sites can run at once. - Short Leash adds
--watchwhen the project has chokidar installed.
- FrankenPHP also gets
- The site keeps its PHP version and Short Leash's
php.ini(PHPRC,PHP_INI_SCAN_DIR) on the server'sPATH. - Swoole comes from Short Leash's own PHP builds, so there's nothing extra to download.
- FrankenPHP is downloaded from its GitHub releases on first use and checked against the SHA-256 digest GitHub publishes (
runtimes::github_tool). - The setting is offered only to Laravel sites that require
laravel/octane. Windows offers FrankenPHP only, because Short Leash's Windows PHP builds have no Swoole.
Consequences
- Local requests take the same path as production on Octane, including per-request state bugs.
- An Octane site is a long-running process. Code changes need
--watch(chokidar) or a restart, unlike PHP-FPM, which reads files on every request. - FrankenPHP runs the PHP it was built with, not the site's PHP version, so the version picker matters only for Swoole and the site's CLI processes.
- RoadRunner isn't offered: it needs another binary and its own config, and nobody has asked for it.