yii2-extensions / franken-php
Yii2 FrankenPHP runtime.
Fund package maintenance!
terabytesoftw
Requires
- php: >=8.1
- yii2-extensions/psr-bridge: ^0.1@dev
Requires (Dev)
- httpsoft/http-message: ^1.1
- infection/infection: ^0.27|^0.30
- maglnet/composer-require-checker: ^4.1
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-strict-rules: ^2.0.3
- phpunit/phpunit: ^10.5
- rector/rector: ^2.1
- symplify/easy-coding-standard: ^12.5
- xepozz/internal-mocker: ^1.4
- yii2-extensions/phpstan: ^0.3
Provides
- bower-asset/bootstrap: ^5.2
- bower-asset/inputmask: 5.0.9
- bower-asset/jquery: 3.6.1
- bower-asset/punycode: ^1.4
- bower-asset/yii2-pjax: ~2.0.1
This package is auto-updated.
Last update: 2025-08-04 15:43:27 UTC
README
Extension for FrankenPHP
A blazing-fast FrankenPHP integration for Yii2 applications that provides seamless HTTP/2, HTTP/3, and WebSocket support with automatic memory management and real-time capabilities.
Features
- ✅ Automatic HTTPS: Built-in automatic HTTPS with Let's Encrypt integration.
- ✅ Early Hints: HTTP/2 Server Push and Early Hints support for faster loading.
- ✅ Graceful Reloading: Hot reload capabilities without downtime.
- ✅ HTTP/2 & HTTP/3 Support: Native support for modern HTTP protocols with multiplexing.
- ✅ Memory Efficient: Smart memory management with configurable limits.
- ✅ Production Ready: Battle-tested with Caddy's proven reliability.
- ✅ Real-time Features: Server-Sent Events (SSE) and WebSocket support.
- ✅ WebSocket Integration: Real-time bidirectional communication capabilities.
- ✅ Worker Mode: Long-running worker processes for maximum performance.
- ✅ Zero Configuration: Works out of the box with sensible defaults.
Quick start
Installation
composer require yii2-extensions/franken-php
Basic Usage
Create your FrankenPHP entry point (public/index.php
):
<?php declare(strict_types=1); use yii2\extensions\frankenphp\FrankenPHP; use yii2\extensions\psrbridge\http\StatelessApplication; defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php'; $config = require dirname(__DIR__) . '/config/web/app.php'; $runner = new FrankenPHP(new StatelessApplication($config)); $runner->run();
FrankenPHP configuration
Create Caddyfile
in your project root (worker mode).
{ auto_https off admin localhost:2019 frankenphp { worker ./index.php } } localhost { log encode zstd br gzip root public/ 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 } }
Standalone Binary
We provide static FrankenPHP binaries for Linux and macOS containing PHP 8.4 and most popular PHP extensions.
On Windows, use WSL to run FrankenPHP.
Download FrankenPHP or copy this line into your terminal to automatically install the version appropriate for your platform.
curl https://frankenphp.dev/install.sh | sh mv frankenphp /usr/local/bin/
To serve the content of the current directory, run.
frankenphp php-server
You can also run command-line scripts with.
frankenphp php-cli /path/to/your/script.php
Docker
Alternatively, Docker images are available:
Clasic mode.
docker run -v .:/app/public \ -p 80:80 -p 443:443 -p 443:443/udp \ dunglas/frankenphp
Worker mode.
docker run -e FRANKENPHP_CONFIG="worker ./public/index.php" \ -v $PWD/Caddyfile:/etc/caddy/Caddyfile \ -v $PWD:/app \ -p 80:80 \ -p 443:443/tcp \ -p 443:443/udp \ --name yii2-frankenphp-rfc dunglas/frankenphp
Start the server
# start the server ./frankenphp run # or with worker mode for production ./frankenphp run --worker public/index.php
Your application will be available at https://localhost
(HTTPS by default) and you can access it via HTTP/2 or HTTP/3.
Documentation
For detailed configuration options and advanced usage: