コンテンツにスキップ
FrankenPHP
Esc
↑↓移動↵開く⌘Jプレビュー

Goで書かれた、モダンなPHPアプリサーバー

FrankenPHP は、PHP アプリ用の新しいアプリサーバーです (Caddy 上に構築) 。また、Go Web サーバーに PHP インタプリタを組み込むためのライブラリでもあります。

curl https://frankenphp.dev/install.sh | sh
始める
  • ネイティブサポート対象
  • Drupal
  • Sulu
  • WordPress
  • Laravel
  • Symfony
  • API Platform
  • Magento

始めよう!

本番環境レベルの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

ワーカーモード

The FrankenPHP mascot in a hard hat, driving an excavator

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つのバイナリ、外部サービス不要。

  • ウォッチャー

    コードを変更するたびにワーカーを自動再起動。

Read the worker docs →

Caddyfile

localhost {
    # 圧縮を有効化(オプション)
    encode zstd br gzip
    # カレントディレクトリ内のPHPファイルを実行し、アセットを配信
    php_server
}

設定はとても簡単!

設定はたった3行:本番環境レベルのPHPサーバーを起動するのに必要なのはこれだけです (自動HTTPS、HTTP/3、zstd圧縮など対応)、Caddy 搭載。

  • HTTPS ✓
  • HTTP/3 ✓
  • zstd · br · gzip ✓
  • Early Hints ✓
ドキュメント →

FrankenPHP 概要

The FrankenPHP elephant and the Go gopher in a laboratory, lightning crackling between them
Go + C + PHP

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)
})
Use FrankenPHP as a Go library →

これまで以上にモダンな PHP!

  • 最新のWebサーバーに公式PHPエグゼキューターを組み込み:Caddy
  • HTTP/1.1、HTTP/2、そして HTTP/3 をネイティブサポート
  • HTTPS証明書の自動生成と更新(Let's Encrypt または ZeroSSL)
  • PHPファイルをドキュメントルートにコピーするだけ、それで完了!
  • PHPウェブアプリやコマンドラインツール向けに、 スタンドアロンで自己実行可能かつ依存関係不要のバイナリをビルド
  • OPcache や XDebug を含む人気のPHP拡張をネイティブサポート!
試してみる
The FrankenPHP mascot hugging a big red heart

Need a hand? We've got heart.

Les-Tilleuls.coop, the cooperative behind FrankenPHP, helps teams migrate, host and speed up their PHP apps.