Configs2026年7月24日·1 分钟阅读

Bref — Serverless PHP on AWS Lambda

Custom AWS Lambda runtimes and tools for deploying PHP applications as serverless functions and web applications.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Bref Serverless PHP
直接安装命令
npx -y tokrepo@latest install cb0aabe3-86f9-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Bref provides custom AWS Lambda runtimes that let PHP applications run natively on Lambda. It packages PHP as a Lambda layer, handles request/response translation, and integrates with the Serverless Framework for deployment.

What Bref Does

  • Provides PHP runtime layers for AWS Lambda supporting PHP 8.x
  • Translates API Gateway and ALB events into PSR-7 or standard PHP requests
  • Supports two modes: HTTP applications (web apps) and event-driven functions
  • Integrates with Laravel, Symfony, and other PHP frameworks
  • Manages deployment through Serverless Framework or AWS CDK

Architecture Overview

Bref publishes pre-compiled PHP binaries as Lambda layers. When a Lambda function is invoked, the Bref runtime bootstraps PHP, receives the event from the Lambda Runtime API, and passes it to your handler. For HTTP workloads, the php-fpm layer runs PHP-FPM as a child process, translating API Gateway events into FastCGI requests. For event-driven workloads, the function layer calls a PHP callable directly. Deployment artifacts are built by the Serverless Framework, which packages your code and references the correct Bref layer ARN.

Self-Hosting & Configuration

  • Requires an AWS account with Lambda, API Gateway, and IAM permissions
  • serverless.yml defines functions, runtime layers, and event triggers
  • PHP extensions are included in the base layer; additional ones available as extra layers
  • Environment variables are set in serverless.yml and accessible via getenv()
  • Local development supported through serverless invoke local or Docker-based emulators

Key Features

  • Pre-built Lambda layers with PHP-FPM and CLI runtimes for PHP 8.x
  • Native support for Laravel (via Laravel Vapor alternative) and Symfony
  • Console command execution on Lambda for cron jobs and queue workers
  • Static asset handling through S3 with CloudFront integration
  • Cold start optimization through smaller deployment packages and layer caching

Comparison with Similar Tools

  • Laravel Vapor — Commercial, Laravel-only; Bref is open-source and framework-agnostic
  • Vercel PHP — Limited PHP support; Bref provides full PHP-FPM runtime on Lambda
  • AWS Lambda Web Adapter — Generic adapter; Bref is purpose-built for PHP with FPM integration
  • Serverless Docker (Fargate) — Container-based, always running; Bref is event-driven with per-request billing

FAQ

Q: Which PHP versions does Bref support? A: Bref maintains layers for actively supported PHP versions, currently PHP 8.1 through 8.3.

Q: Can I use Bref with Laravel? A: Yes. Bref has dedicated documentation and packages for running Laravel on Lambda, including queue and scheduler support.

Q: How do I handle static assets? A: Static files are typically served from S3 behind CloudFront. Bref provides tooling to separate assets from the Lambda deployment package.

Q: What about cold starts? A: PHP-FPM cold starts on Lambda typically range from a few hundred milliseconds to about one second. Provisioned concurrency can eliminate them for latency-sensitive workloads.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产