backbrain / frankenphp-symfony

FrankenPHP runtime for Symfony

v1.0.0 2024-04-05 12:45 UTC

This package is auto-updated.

Last update: 2024-09-20 16:35:29 UTC


README

FrankenPHP 的运行时。

如果你是首次接触 Symfony 运行时组件,请在 主 README 中了解更多。

安装

composer require backbrain/frankenphp-symfony

使用方法

为您的应用程序定义环境变量 APP_RUNTIME

Dotenv 组件在运行时组件之后执行,因此 APP_RUNTIME 必须在您的容器中可用。

使用 FRANKENPHP_ 环境变量来配置运行时。如果省略,则使用默认值。

docker run \
    -e FRANKENPHP_CONFIG="worker ./public/index.php" \
    -e APP_RUNTIME=Runtime\\FrankenPhpSymfony\\Runtime \
    -e FRANKENPHP_LOOP_MAX=500 \
    -e FRANKENPHP_KERNEL_REBOOT=never \
    -v $PWD:/app \
    -p 80:80 -p 443:443 \
    dunglas/frankenphp
// public/index.php

use App\Kernel;

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function (array $context) {
    return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};

选项

  • frankenphp_loop_max: 工作进程必须重启以防止奇怪的内存泄漏的请求数量(默认为 500,设置为 -1 则永不重启)
  • frankenphp_kernel_reboot: 是否在请求后重启内核(默认为 never,设置为 always 则在每个请求后重启)