FrankenPHP application runtime
Overview
FrankenPHP is a fast and modern server for PHP developed by Kevin Dunglas built on top of the Caddy web server. It’s a seamless drop-in replacement for PHP-FPM or Apache with mod_php, designed to enhance your PHP applications with advanced capabilities.
It comes with many extensions and features such as early hints (HTTP 103), real-time capabilities with its built-in Mercure hub. FrankenPHP can also make your Laravel and Symfony projects faster than ever through their official integrations with the worker mode. Deploying PHP applications with FrankenPHP on Clever Cloud is straightforward and requires no complex configuration, nor Docker container.
Create your FrankenPHP application
To create a new FrankenPHP application, use the Clever Cloud Console or Clever Tools:
clever create --type frankenphpFrankenPHP applications can’t be deployed on a pico instance, XS is the default instance type
Configure your FrankenPHP application
Mandatory needs
FrankenPHP runtime only requires a working web application, with an index.php or index.html file. If you need to serve files from a specific directory, set the CC_WEBROOT environment variable, relative to the root of your project (default: /).
FrankenPHP version and tools
FrankenPHP currently deployed version on Clever Cloud is 1.13.5 based on PHP 8.5.12 and Caddy server 2.11.9. Virtual machine image includes multiple tools from the PHP ecosystem such as Composer or Symfony CLI. The php command available in hooks and scripts uses frankenphp php-cli under the hood.
FrankenPHP uses this version whatever the value of CC_PHP_VERSION.
Composer native support
If a composer.json file is detected at the root of your project, it will be used to install dependencies during building phase with --no-interaction --no-progress --no-scripts --no-dev flags. To override the base flags (--no-interaction --no-progress --no-scripts), set the CC_PHP_COMPOSER_FLAGS environment variable.
To install development dependencies, set the CC_PHP_DEV_DEPENDENCIES environment variable to install. This removes the --no-dev flag independently of CC_PHP_COMPOSER_FLAGS.
Use a local Composer version
If you put a composer.phar file at the root of your project, it will be used to install dependencies.
Private Composer repositories
Composer can authenticate with private package repositories through the COMPOSER_AUTH environment variable. Its value is a JSON object containing Composer authentication settings, such as HTTP Basic, OAuth or an access token.
For example, to use Private Packagist, add its repository to your composer.json, replacing ORGANISATION with its short name:
{
"repositories": [
{
"type": "composer",
"url": "https://repo.packagist.com/ORGANISATION"
},
{
"packagist.org": false
}
]
}Then define COMPOSER_AUTH for your application with the username and token provided by Private Packagist:
{
"http-basic": {
"repo.packagist.com": {
"username": "PACKAGIST_USERNAME",
"password": "PACKAGIST_TOKEN"
}
}
}Composer reads this variable automatically during composer install. Never commit credentials to your repository. If you use a local auth.json file, add it to .gitignore. See the Composer authentication documentation for other providers and authentication methods. For a private Git repository accessed over SSH, configure a private SSH key instead.
Custom PHP configuration
To load your own PHP configuration directives, put a php.ini file at the root of your project. FrankenPHP will automatically use it.
FrankenPHP and Materia KV
Materia KV is Clever Cloud’s distributed serverless key-value store based on FoundationDB, compatible with existing ecosystems such as Redis®, with TTL for sessions support and JSON commands.
To manage Materia KV data with FrankenPHP, use the included redis extension in your PHP code and configure it with your add-on URL, port and token as password. For now, you need to use the tcp mode and 6378 port.
Worker mode
With FrankenPHP worker mode, a script of your project is kept in memory to handle incoming requests in a few milliseconds. Define the path to this script, relative to the root of your project, with the CC_FRANKENPHP_WORKER environment variable (e.g. /public/worker.php). The worker script must be located within the webroot directory. It’s supported by design by Laravel Octane and Symfony Runtime projects.
- Learn more about FrankenPHP worker mode
- Learn more about Laravel Octane
- Learn more about Symfony Runtime
Configurable port
FrankenPHP listens on port 8080, or on port 9000 when a Request Flow middleware runs in front of it: Clever Cloud sets it for you. To force another port, for a setup of your own, set the CC_FRANKENPHP_PORT environment variable.
Custom FrankenPHP run command
To override the default server behavior, set the CC_RUN_COMMAND environment variable. When defined, it completely replaces the default frankenphp php-server command. Use it to define flags such as --debug, --mercure or --no-compress:
CC_RUN_COMMAND='frankenphp php-server --listen 0.0.0.0:$PORT --debug --mercure'You can also use it to load a custom Caddyfile:
CC_RUN_COMMAND="frankenphp run --config /path/to/Caddyfile"Use FrankenPHP to execute PHP scripts as Clever Tasks
FrankenPHP can be used to execute PHP scripts. On Clever Cloud, to run such workloads as Clever Tasks, configure an application as Tasks from the Information panel in the Console or with Clever Tools:
clever create --type frankenphp --task "frankenphp php-cli path/to/task.php"
clever deploy # or clever restart if there is no code changeIncluded extensions
FrankenPHP on Clever Cloud comes with a set included PHP extensions: amqp,apcu,ast,bcmath,brotli,bz2,calendar,ctype,curl,dba,deepclone,dom,exif,fileinfo,filter,ftp,gd,gettext,gmp,iconv,igbinary,imagick,intl,ldap,lz4,mbregex,mbstring,memcached,mysqli,mysqlnd,opcache,openssl,parallel,password-argon2,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,ssh2,sysvmsg,sysvsem,sysvshm,tidy,tokenizer,xlswriter,xml,xmlreader,xmlwriter,xsl,xz,yaml,zip,zlib,zstd