How FrankenPHP Can Replace Nginx + PHP‑FPM for Faster Laravel Development
This guide walks through setting up FrankenPHP on Ubuntu, integrating it with Laravel and Octane, configuring Caddy, and benchmarking performance against traditional Nginx + PHP‑FPM, showing significant speed improvements.
Environment Preparation
Use Ubuntu 20.04.6 LTS with PHP 8.4.7, Nginx 1.24.0, Laravel 12.20.0, and FrankenPHP v1.8.0 (PHP 8.4.10, Caddy v2.10.0).
# Install FrankenPHP
curl https://frankenphp.dev/install.sh | sh
mv frankenphp /usr/local/bin/
# Serve the public/ directory
frankenphp php-server -r public/
# Run a CLI script
frankenphp php-cli script.phpOr use Docker:
# Serve the public/ directory
docker run -v $PWD:/app/public -p 443:443/tcp -p 443:443/udp dunglas/frankenphp
# Run a CLI script
docker run -v $PWD:/app dunglas/frankenphp php script.phpLaravel Installation and Octane Integration
composer global require laravel/installer
laravel new franken-demo
composer require laravel/octane
php artisan octane:installDuring Octane installation, select FrankenPHP as the server driver.
Start the application:
/usr/bin/php8.4 artisan octane:start --server=frankenphp --host=0.0.0.0 --port=8008FrankenPHP Quick Start
Check the version: /usr/local/bin/frankenphp version Start a web server with a single command (default directory is the current one): /usr/local/bin/frankenphp php-server Or specify a directory:
/usr/local/bin/frankenphp php-server -r ./public/Run a PHP script directly:
/usr/local/bin/frankenphp php-cli ./public/info.phpConfiguration for Laravel Projects
Create a Caddyfile in the Laravel root:
{
frankenphp
# Disable default ports to avoid conflict with local Nginx
auto_https off
http_port 8880
https_port 8443
}
http://franken.demo:8006 {
# Set the webroot to the public/ directory
root public/
encode zstd br gzip
php_server {
try_files {path} index.php
}
}Start FrankenPHP from the project root:
/usr/local/bin/frankenphp runPerformance Benchmarking
Traditional Nginx + PHP‑FPM test (1000 requests, 20 concurrency): ab -n 1000 -c 20 http://franken.demo/hello Result: ~100 requests/sec, 199 ms average latency.
FrankenPHP classic mode (no memory resident):
/usr/local/bin/frankenphp run
ab -n 1000 -c 20 http://franken.demo:8006/helloResult: ~116 requests/sec, 172 ms average latency.
FrankenPHP worker mode with Laravel Octane:
/usr/bin/php8.4 artisan octane:start --server=frankenphp --host=0.0.0.0 --port=8008
ab -n 1000 -c 20 http://franken.demo:8008/helloResult: ~209 requests/sec, 96 ms average latency.
The benchmarks clearly show that FrankenPHP, especially when combined with Laravel Octane, delivers a substantial performance boost over the classic Nginx + PHP‑FPM stack.
Conclusion
FrankenPHP simplifies PHP deployment by merging PHP, Caddy, and a high‑performance server into a single binary, reducing configuration complexity and improving request handling speed. For Laravel developers, integrating FrankenPHP via Octane offers a compelling path to faster local development and testing.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Tech Hub
Sharing cutting-edge internet technologies and practical AI resources.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
