https://github.com/yii2-extensions/franken-php
Supercharge your Yii2 applications with FrankenPHP blazing-fast HTTP server.
https://github.com/yii2-extensions/franken-php
frankenphp psr-7 worker yii2 yii2-extensions
Last synced: 4 months ago
JSON representation
Supercharge your Yii2 applications with FrankenPHP blazing-fast HTTP server.
- Host: GitHub
- URL: https://github.com/yii2-extensions/franken-php
- Owner: yii2-extensions
- License: other
- Created: 2025-08-03T16:39:17.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-12-03T14:59:24.000Z (6 months ago)
- Last Synced: 2025-12-06T19:29:41.956Z (6 months ago)
- Topics: frankenphp, psr-7, worker, yii2, yii2-extensions
- Language: PHP
- Homepage:
- Size: 95.7 KB
- Stars: 18
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
FrankenPHP
Supercharge your Yii2 applications with FrankenPHP blazing-fast HTTP server
HTTP/2, HTTP/3, automatic memory management, and worker mode for ultimate performance
## Features

## Demo
[](https://github.com/yii2-extensions/app-basic/tree/franken-php)
Explore the ready-to-run Yii2 + FrankenPHP application template.
### Installation
```bash
composer require yii2-extensions/franken-php:^0.1.0@dev
```
### Quick start
Create your FrankenPHP entry point (`web/index.php`)
```php
safeLoad();
// production default (change to 'true' for development)
define('YII_DEBUG', $_ENV['YII_DEBUG'] ?? false);
// production default (change to 'dev' for development)
define('YII_ENV', $_ENV['YII_ENV'] ?? 'prod');
require_once dirname(__DIR__) . '/vendor/yiisoft/yii2/Yii.php';
$config = require_once dirname(__DIR__) . '/config/web.php';
$runner = new FrankenPHP(new StatelessApplication($config));
$runner->run();
```
### FrankenPHP configuration
Create `Caddyfile` in your project root (worker mode)
```caddyfile
{
auto_https off
admin localhost:2019
https_port 8443
frankenphp {
worker ./web/index.php
}
}
localhost {
tls ./web/ssl/localhost.pem ./web/ssl/localhost-key.pem
log
encode zstd br gzip
root ./web
# compatibility headers to enable X-Sendfile support in PHP frameworks (Yii2/Symfony)
# see: https://github.com/php/frankenphp/blob/main/docs/x-sendfile.md
request_header X-Sendfile-Type x-accel-redirect
request_header X-Accel-Mapping ../private-files=/private-files
intercept {
@sendfile header X-Accel-Redirect *
handle_response @sendfile {
root private-files/
rewrite * {resp.header.X-Accel-Redirect}
method * GET
header -X-Accel-Redirect
file_server
}
}
php_server {
try_files {path} index.php
}
}
```
> [!WARNING]
> **Note:** Using custom certificates (like `tls ./web/ssl/localhost.pem ./web/ssl/localhost-key.pem`) avoids browser trust warnings that occur with Caddy's automatic self-signed certificates.
> For local development, consider using [mkcert](https://github.com/FiloSottile/mkcert) to generate trusted local certificates.
> If you want to use Caddy's automatic self-signed certificates for local development, you can remove this line.
### Standalone Binary
We provide static FrankenPHP binaries for Linux and macOS containing [PHP 8.4](https://www.php.net/releases/8.4/en.php)
and most popular PHP extensions.
On Windows, use [WSL](https://learn.microsoft.com/windows/wsl/) to run FrankenPHP.
[Download FrankenPHP](https://github.com/php/frankenphp/releases) or copy this line into your terminal to automatically
install the version appropriate for your platform.
```bash
curl https://frankenphp.dev/install.sh | sh
mv frankenphp /usr/local/bin/
```
To run your application, you can use the following command.
```bash
./frankenphp run --config ./Caddyfile --watch
```
### Docker
Alternatively, [Docker images](https://frankenphp.dev/docs/docker/) are available.
#### Worker mode
Gitbash/Windows
```bash
docker run \
-e CADDY_GLOBAL_OPTIONS="auto_https off" \
-e CADDY_SERVER_EXTRA_DIRECTIVES="tls /app/web/ssl/localhost.pem /app/web/ssl/localhost-key.pem" \
-e FRANKENPHP_CONFIG="worker ./web/index.php" \
-e SERVER_NAME="https://localhost:8443" \
-e SERVER_ROOT="./web" \
-v "//k/yii2-extensions/app-basic:/app" \
-p 8443:8443 \
-p 8443:8443/udp \
--name yii2-frankenphp-worker \
dunglas/frankenphp
```
> **Note:** Paths in the example (`//k/yii2-extensions/app-basic`) are for demonstration purposes only.
> Replace them with the actual path to your Yii2 project on your system.
Linux/WSL
```bash
docker run \
-e CADDY_GLOBAL_OPTIONS="auto_https off" \
-e CADDY_SERVER_EXTRA_DIRECTIVES="tls /app/web/ssl/localhost.pem /app/web/ssl/localhost-key.pem" \
-e FRANKENPHP_CONFIG="worker ./web/index.php" \
-e SERVER_NAME="https://localhost:8443" \
-e SERVER_ROOT="./web" \
-v $PWD:/app \
-p 8443:8443 \
-p 8443:8443/udp \
--name yii2-frankenphp-worker \
dunglas/frankenphp
```
> [!IMPORTANT]
> Your application will be available at `https://localhost:8443` or at the address set in the `Caddyfile`.
### Development & Debugging
For enhanced debugging capabilities and proper time display in FrankenPHP, install the worker debug extension.
```bash
composer require --dev yii2-extensions/worker-debug:^0.1
```
Add the following to your development configuration (`config/web.php`):
```php
WorkerDebugModule::class,
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];
}
```
### File Upload Handling
For enhanced file upload support in worker environments, use the PSR-7 bridge UploadedFile class instead of the standard
Yii2 implementation.
```php
error === UPLOAD_ERR_OK) {
$file->saveAs('@webroot/uploads/' . $file->name);
}
return $this->asJson(['status' => 'uploaded']);
}
}
```
## Documentation
For detailed configuration options and advanced usage.
- ๐ [Installation Guide](docs/installation.md)
- โ๏ธ [Configuration Reference](docs/configuration.md)
- ๐งช [Testing Guide](docs/testing.md)
- ๐ ๏ธ [Development Guide](docs/development.md)
## Package information
[](https://www.php.net/releases/8.1/en.php)
[](https://github.com/yiisoft/yii2/tree/2.0.53)
[](https://github.com/yiisoft/yii2/tree/22.0)
[](https://packagist.org/packages/yii2-extensions/franken-php)
[](https://packagist.org/packages/yii2-extensions/franken-php)
## Quality code
[](https://codecov.io/github/yii2-extensions/franken-php)
[](https://github.com/yii2-extensions/franken-php/actions/workflows/static.yml)
[](https://github.com/yii2-extensions/franken-php/actions/workflows/linter.yml)
[](https://github.styleci.io/repos/1031393416?branch=main)
## Our social networks
[](https://x.com/Terabytesoftw)
## License
[](LICENSE)