FrankenPHP
Modern PHP app server built on Caddy with automatic HTTPS.
Overview
FrankenPHP is a revolutionary PHP application server that combines the power of Go's Caddy web server with PHP's CGO bindings, creating a modern alternative to traditional PHP-FPM and Apache setups. Built by Kévin Dunglas, FrankenPHP eliminates the overhead of spawning new PHP processes for each request by keeping PHP workers in memory, similar to Swoole or RoadRunner, while maintaining full compatibility with existing PHP applications. The server includes Caddy's automatic HTTPS provisioning through Let's Encrypt, HTTP/3 support, and implements cutting-edge features like 103 Early Hints for improved performance.
This Docker configuration leverages FrankenPHP's worker mode capabilities to serve PHP applications with dramatically reduced latency and increased throughput compared to traditional setups. The integration with Caddy provides zero-configuration HTTPS, automatic certificate management, and modern HTTP protocol support out of the box. FrankenPHP's unique architecture allows it to handle thousands of concurrent connections while consuming significantly less memory than conventional PHP deployment methods.
Development teams building high-performance PHP applications, Laravel and Symfony projects requiring enterprise-grade performance, and organizations seeking to modernize their PHP infrastructure will benefit most from this setup. FrankenPHP is particularly valuable for applications that need real-time features, WebSocket support, or handle high concurrent loads, making it ideal for modern web applications, APIs, and microservices that demand both performance and simplicity.
Key Features
- Worker mode keeps PHP processes in memory for lightning-fast response times without process spawning overhead
- Native Laravel Octane and Symfony Runtime integration for zero-configuration framework optimization
- HTTP/3 and HTTP/2 support with server push capabilities for improved client performance
- 103 Early Hints implementation allows browsers to preload resources before full response
- Automatic HTTPS certificate provisioning and renewal through Let's Encrypt integration
- Real-time WebSocket support built directly into the PHP runtime without external dependencies
- Graceful worker reloading enables zero-downtime deployments and configuration changes
- Built-in request/response pooling reduces garbage collection pressure and memory allocations
Common Use Cases
- 1High-traffic Laravel applications requiring sub-millisecond response times with Octane integration
- 2Real-time web applications needing WebSocket connections for chat, notifications, or live updates
- 3API-heavy microservices architecture where PHP service performance is critical
- 4E-commerce platforms handling thousands of concurrent users during peak shopping periods
- 5Content management systems requiring fast page generation with automatic HTTPS
- 6Development environments where quick iteration and hot-reloading improve productivity
- 7SaaS applications needing enterprise-grade performance without complex infrastructure setup
Prerequisites
- Docker Engine 20.10+ and Docker Compose 2.0+ for container orchestration support
- Minimum 512MB RAM available for FrankenPHP worker processes and Caddy operations
- Ports 80 and 443 available on host system for HTTP/HTTPS traffic handling
- Basic understanding of Caddyfile syntax for server configuration and routing rules
- PHP application structure with public directory containing index.php entry point
- Domain name with proper DNS configuration if using automatic HTTPS certificates
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 frankenphp: 3 image: dunglas/frankenphp:latest4 container_name: frankenphp5 restart: unless-stopped6 volumes: 7 - ./app:/app/public8 - ./Caddyfile:/etc/caddy/Caddyfile:ro9 ports: 10 - "80:80"11 - "443:443"12 networks: 13 - franken-network1415networks: 16 franken-network: 17 driver: bridge.env Template
.env
1# FrankenPHP with CaddyUsage Notes
- 1Docs: https://frankenphp.dev/docs/
- 2Built on Caddy - automatic HTTPS with Let's Encrypt
- 3Worker mode keeps PHP in memory (like Swoole/RoadRunner)
- 4103 Early Hints support for faster page loads
- 5Native support for Laravel, Symfony - just works
- 6Configure with Caddyfile: php_server directive
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 frankenphp:5 image: dunglas/frankenphp:latest6 container_name: frankenphp7 restart: unless-stopped8 volumes:9 - ./app:/app/public10 - ./Caddyfile:/etc/caddy/Caddyfile:ro11 ports:12 - "80:80"13 - "443:443"14 networks:15 - franken-network1617networks:18 franken-network:19 driver: bridge20EOF2122# 2. Create the .env file23cat > .env << 'EOF'24# FrankenPHP with Caddy25EOF2627# 3. Start the services28docker compose up -d2930# 4. View logs31docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/frankenphp/run | bashTroubleshooting
- Worker process crashes with memory errors: Increase container memory limits and tune PHP memory_limit setting in worker mode
- Automatic HTTPS fails with certificate errors: Verify domain DNS points to server and ports 80/443 are publicly accessible
- PHP application returns 502 errors: Check that app directory contains valid PHP files and public/index.php entry point exists
- WebSocket connections fail to establish: Ensure Caddyfile includes proper WebSocket upgrade directives and routing
- High memory usage in worker mode: Implement worker recycling strategies and tune FRANKENPHP_WORKER environment variables
- Static assets not serving correctly: Verify Caddyfile file_server directives and check volume mount paths match application structure
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
frankenphp
Tags
#frankenphp#php#caddy#modern#worker-mode
Category
Web Servers & Reverse ProxiesAd Space
Shortcuts: C CopyF FavoriteD Download