nix flake init --template github:panakour/php-nix-flake-templatesTraditional setup using Caddy as a reverse proxy to PHP-FPM. Supports all PHP versions from nix-phps.
nix flake init --template github:panakour/php-nix-flake-templates#frankenphpModern setup using FrankenPHP - a PHP app server built on Caddy with PHP embedded directly. No separate PHP-FPM process needed.
After initializing either template, choose your PHP version by editing flake.nix:
phpVersion = "84"; # Change to your desired versionThen enter the development environment:
nix develop- All PHP versions supported by nix-phps with easy switching
- Xdebug pre-configured for debugging
- Composer for dependency management
- Development-optimized PHP configuration
- Cross-platform (Linux, macOS, WSL)
- Enter the development environment:
nix develop - Start the Caddy server:
./nix/start-caddy.sh - Visit your site: http://localhost:8000
- Stop services:
pkill -f 'php-fpm|caddy'
- Enter the development environment:
nix develop - Start FrankenPHP:
./nix/start-frankenphp.sh - Visit your site: http://localhost:8000
- Stop services:
pkill -f frankenphp
Note: FrankenPHP is built against the same PHP version and extensions from nix-phps, so the server and CLI use the same PHP. The first
nix developmay take longer as FrankenPHP is compiled from source with your chosen PHP.
By default, both templates use the latest Composer. If you need to use legacy Composer version 1 for compatibility with older projects, you can modify the buildInputs in your flake.nix:
buildInputs = [
php
php.packages.composer-1 # Use composer 1 instead
# ...
];Change php.packages.composer to php.packages.composer-1 to use the legacy version.
Contributions are welcome! Feel free to submit issues and enhancement requests.
MIT License - see LICENSE file for details.