Bref: Serverless PHP Framework and Cloud Hosting

website·Indexed Apr 12, 2026

https://bref.sh/

Bref is an open-source framework that simplifies deploying PHP applications to AWS Lambda. It manages infrastructure, scaling, and WebSocket connections for real-time messaging. The ecosystem includes the open-source CLI for self-managed deployments and Bref Cloud, a managed platform offering unified monitoring, security, and team collaboration. Documentation covers deployment via Serverless Framework, CDK, or Docker, configuration of PHP runtimes, database integration with RDS and PlanetScale, and optimization strategies for cold starts and performance.

Tokens
18.6K
Snippets
34
Records
216
Agent score
50%

What's inside Bref

  1. Why external cache storage is required on AWS Lambda

    The filesystem is read-only on AWS Lambda except for /tmp. However, /tmp is not shared across Lambda instances. When scaling or redeploying, new instances start with an empty cache. Use Redis or DynamoDB for shared caching across all instances. DynamoDB is easier to set up (pay per use) while Redis offers faster response times but requires VPC and instance management.
  2. Bref components and capabilities

    Bref is an open-source Composer package for deploying PHP to AWS Lambda. It provides: PHP runtimes for Lambda, deployment tooling via the serverless framework, and deep integrations for Laravel and Symfony. It configures and deploys applications using the serverless CLI, which offers a simple YAML configuration format and extensive community resources.
  3. PHP-FPM runtime architecture on AWS Lambda

    Bref runs PHP applications on AWS Lambda using PHP-FPM. API Gateway receives HTTP requests and forwards them to the Lambda function via the FastCGI protocol. The Bref runtime starts PHP-FPM inside the Lambda environment, acting like Apache or Nginx. The performance overhead is less than 1ms. This allows full Laravel or Symfony applications to run on Lambda without modification.
  4. Serverless use cases for PHP with Bref

    Bref supports multiple serverless use cases: Jobs/Cron (queue processing with pay-per-use billing), APIs (performance similar to VPS with ~0.5% cold starts), Websites (assets via S3/CloudFront), Legacy applications (requires code adaptation), Event-driven microservices (orchestrated via serverless.yml), Websockets (possible but undocumented), and Real-time applications (cold starts can exceed 100ms latency).
  5. Application definition in Bref Cloud

    An application is a deployment unit (CloudFormation stack) representing a single PHP project. It can be a Laravel, Symfony, or any other PHP application. One application can be deployed to multiple environments (dev, staging, production). If a JS frontend (like React) and PHP backend are deployed together in a single config file, they count as a single application.
  6. How Bref Cloud securely accesses AWS accounts

    Bref Cloud uses IAM roles with temporary credentials instead of long-lived AWS access keys. When you connect an AWS account, Bref Cloud creates a BrefCloudAccess IAM role in your account. Access works via a two-role chain: (1) Bref Cloud assumes the BrefCloudAccessor role in its own AWS account, (2) uses that to assume your BrefCloudAccess role, (3) receives temporary credentials valid for a short period. These credentials are used for operations like deploying Lambda functions or retrieving logs, then discarded. The BrefCloudAccessor role acts as an additional security layer between the PHP application and your account.
  7. Serverless billing model on AWS Lambda

    AWS Lambda bills only for actual usage: request count and execution duration. No charges occur during idle periods between requests, jobs, or events. Even if Lambda scales to multiple concurrent instances, you pay only for active request duration. This means 1 job running 10 minutes costs roughly the same as 600 jobs running 1 second in parallel.
  8. AWS Lambda filesystem structure and constraints

    Lambda has three key directories: /opt (runtimes and layers), /var/task (application code, limited to 250MB), and /tmp (temporary files). The filesystem is read-only except for /tmp. When scaling, /tmp is not shared between lambda instances, so data stored there can be lost at any time. If you exceed the 250MB limit, deploy via Docker images instead.
  9. Bref: Serverless PHP on AWS Lambda

    Bref is an open-source project that deploys PHP applications to AWS Lambda. It sets up the rest of the infrastructure using serverless services. Define your application in a serverless.yml file and deploy with serverless deploy. Benefits include automatic scaling, cost-efficiency (pay only when code runs), and extensibility via CloudFormation, AWS CDK, or Terraform.
  10. Memory size determines CPU power in AWS Lambda

    In AWS Lambda, memory is proportional to CPU power. A 1024M lambda has 2x the CPU of a 512M lambda. PHP is single-threaded, so using more than 1 CPU (1,792M+) provides no benefit. The recommended setting is 1024M, which is Serverless's default.
  11. Sentry integration for AWS Lambda features

    The Sentry integration for PHP on AWS Lambda provides: error tracking for Lambda-specific errors outside PHP-FPM (timeouts, 'response too big' errors); non-HTTP exception tracking for SQS, EventBridge, S3 handlers and similar event-driven invocations; cold start and Bref startup duration tracking in performance traces; Lambda handler performance tracing for event-driven functions; and AWS SDK call measurement for troubleshooting performance issues.
  12. Video overview of how Bref works with AWS Lambda

    This page provides a video explanation of how Bref runs PHP on AWS Lambda. The low-level implementation details are not required knowledge for using Bref in production; this resource is for developers curious about the underlying architecture. Related documentation covers specific runtimes and serverless cost considerations.