FrankenPHP embeds PHP into Caddy and can run conventional web apps or persistent workers.
What It Does and When to Use It
Run the relevant deployment or container command in the intended trusted environment. The web server handles HTTP, the PHP worker executes scripts, and CLI has separate configuration and lifecycle.
Requirements, Inputs and Expected Behavior
Confirm the runtime, extension, environment variables, and permissions before running the examples in production. Worker mode keeps process state across requests and requires resetting request-specific state.
Example 1: Basic Operation
Run the relevant deployment or container command in the intended trusted environment.
docker run --rm -p 8080:80 -v "$PWD/public:/app/public:ro" dunglas/frankenphp:1-php8.4
Example 2: Behavior and Validation
Confirm PHP version, extensions and INI paths in the target runtime.
php -v
php -m | grep -E 'pdo|openssl|mbstring'
php --ini
Practical Example: Application Use
Check actual service health and log output; adapt host and service names to deployment.
curl -fsS http://127.0.0.1/health || exit 1
sudo journalctl -n 30 --no-pager
Important Behavior and Edge Cases
The second example highlights: Confirm PHP version, extensions and INI paths in the target runtime. The practical example adds: Check actual service health and log output; adapt host and service names to deployment.
Comparison with Related Approaches
| Approach | What changes |
|---|---|
| Web server, worker and PHP CLI | The web server handles HTTP, the PHP worker executes scripts, and CLI has separate configuration and lifecycle. |
| Choosing safely | Check the effective configuration in the SAPI serving requests before changing production. |
Common Beginner Mistakes
| Mistake | Correct approach |
|---|---|
| Assuming successful execution proves the result is usable | Check the return value, required extension, and observable output of the specific operation. |
| Ignoring runtime and environment differences | Verify PHP version, SAPI, operating system, service access, and permissions before deployment. |
| Skipping operational constraints | Worker mode keeps process state across requests and requires resetting request-specific state. |
Key Takeaways
- FrankenPHP embeds PHP into Caddy and can run conventional web apps or persistent workers.
- Check actual service health and log output; adapt host and service names to deployment.
- Check the effective configuration in the SAPI serving requests before changing production.