Goで書かれた、モダンなPHPアプリサーバー
FrankenPHP は、PHP アプリ用の新しいアプリサーバーです (Caddy 上に構築) 。また、Go Web サーバーに PHP インタプリタを組み込むためのライブラリでもあります。
curl https://frankenphp.dev/install.sh | sh始めよう!
本番環境レベルのPHPサーバーを、たった1つのコマンドで起動!
# Linux または macOS に FrankenPHP をインストール
curl https://frankenphp.dev/install.sh | sh
# または Windows の場合、PowerShell で
irm https://frankenphp.dev/install.ps1 | iex
# public/ ディレクトリを提供
frankenphp php-server -r public/
# コマンドラインスクリプトを実行
frankenphp php-cli script.php# public/ ディレクトリを提供
docker run -v $PWD:/app/public \
-p 443:443/tcp -p 443:443/udp \
dunglas/frankenphp
# コマンドラインスクリプトを実行
docker run -v $PWD:/app \
dunglas/frankenphp php script.phpAnatomy of a modern PHP server.
Every part was stitched on for a reason. Here's what keeps the creature alive.
The bolts
Automatic HTTPS
Certificates issued, renewed and revoked for you, with Let's Encrypt or ZeroSSL.
The brain
Worker mode
Boots your app once and keeps it in memory, ready in milliseconds.
The stitches
Caddy inside
The official PHP executor sewn into Caddy, with every Caddy module at hand.
One binary. No PHP-FPM.
ワーカーモード
public/index.php
<?php
// Boot your app once
require __DIR__.'/vendor/autoload.php';
$app = new \App\Kernel();
$app->boot();
$handler = static function () use ($app) {
echo $app->handle($_GET, $_POST, $_COOKIE, $_FILES, $_SERVER);
};
// …then serve request after request
while (\frankenphp_handle_request($handler)) {
gc_collect_cycles();
}ワーカースクリプト
アプリを一度起動すると、メモリに常駐します!
ストレートフォワード
Symfony、API Platform、Laravelでネイティブにサポート…
シンプル
古き良きスーパーグローバルを使用:PSR-7は不要。
高速
ベンチマークによると、 API PlatformアプリでFPMより3.5倍高速。
効率的
FrankenPHPはGoとCで書かれています。 Goの代表的な機能「ゴルーチン」に依存しています!
オプション
アプリがワーカーモードに対応していなくても、そのまま提供可能。
簡単デプロイ
プロセス内で実行:1つのバイナリ、外部サービス不要。
ウォッチャー
コードを変更するたびにワーカーを自動再起動。
Caddyfile
localhost {
# 圧縮を有効化(オプション)
encode zstd br gzip
# カレントディレクトリ内のPHPファイルを実行し、アセットを配信
php_server
}FrankenPHP 概要
拡張性
PHP 8.2+、ほとんどのPHP拡張機能、そしてすべてのCaddyモジュールに対応。
1つのサービスだけ
シンプルさを重視して設計:1つのサービス、1つのバイナリ! FrankenPHPはPHP-FPMを必要とせず、Goウェブサーバー向けに特別に作られた独自のSAPIを使用します。
簡単デプロイ
クラウドネイティブアプリをDockerイメージとして提供。 Kubernetesやすべての最新クラウドプラットフォームに対応。 PHPアプリをスタンドアロンの自己実行可能な静的バイナリとしてパッケージ化することも可能です。
ワーカーモード
アプリケーションを一度起動してメモリに保持! 数ミリ秒でリクエストを処理できるようになります。
103 Early Hints
Early Hintsはウェブプラットフォームの新機能で、ウェブサイトの読み込み時間を30%短縮できます。 FrankenPHPはEarly Hintsをサポートする唯一のPHP SAPIです!
リアルタイム
組み込みのMercureハブ。 PHPアプリから接続中のすべてのブラウザにイベントを送信し、JavaScriptイベントとして即座に受信!
Brotli、Zstandard、Gzip圧縮
最新の圧縮フォーマットを標準でサポート。
構造化ログ
ログにより明確なフォーマットと詳細を追加。
Prometheusメトリクスとトレーシング
組み込みのPrometheusサポート!
HTTP/2 & HTTP/3
HTTPS、HTTP/2、HTTP/3をネイティブサポート。
HTTPS自動化
HTTPS証明書の自動生成、更新、失効をサポート。
優雅なリロード
優雅なリロードにより、ダウンタイムゼロでアプリをデプロイ。
Born in a lab. Written in Go.
FrankenPHP is a Caddy module and a library: embed the PHP interpreter in any Go program and serve PHP scripts through net/http.
server, _ := frankenphp.NewServer("public/")
frankenphp.Init(frankenphp.WithServer(server))
defer frankenphp.Shutdown()
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
server.ServeHTTP(w, r)
})これまで以上にモダンな PHP!
- 最新のWebサーバーに公式PHPエグゼキューターを組み込み:Caddy
- HTTP/1.1、HTTP/2、そして HTTP/3 をネイティブサポート
- HTTPS証明書の自動生成と更新(Let's Encrypt または ZeroSSL)
- PHPファイルをドキュメントルートにコピーするだけ、それで完了!
- PHPウェブアプリやコマンドラインツール向けに、 スタンドアロンで自己実行可能かつ依存関係不要のバイナリをビルド
- OPcache や XDebug を含む人気のPHP拡張をネイティブサポート!
Need a hand? We've got heart.
Les-Tilleuls.coop, the cooperative behind FrankenPHP, helps teams migrate, host and speed up their PHP apps.