Other frameworks
Getting Started

Getting started - Bref with any framework

This guide will help you deploy your first PHP application on AWS Lambda. The instructions below can be adapted to work with any framework.

If you are using Laravel or Symfony, check out the dedicated guides instead:


First, follow the Setup guide to create an AWS account and install the necessary tools.

Next, in an empty directory, install Bref using Composer:

composer require bref/bref

Make sure that the version of Bref that was installed is 1.0 or greater.

Then let's start by initializing a new project by running:

vendor/bin/bref init

Accept all the defaults by pressing "Enter". The following files will be created in your project:

  • index.php contains the code of your application
  • serverless.yml contains the configuration for deploying on AWS

You are free to edit index.php.

To deploy an existing application, you can delete index.php and edit serverless.yml to point to your existing index file (for example it may be another file like public/index.php). You can also create the serverless.yml file manually:

service: app
    name: aws
    region: us-east-1
        handler: index.php
        runtime: php-81-fpm
            -   httpApi: '*'
    patterns: # Exclude files from deployment
        - '!node_modules/**'
        - '!tests/**'
    - ./vendor/bref/bref


To deploy, run:

serverless deploy

Once the command finishes, it should print a URL like this one:

Open this URL and you should see your application: index.php is running on Lambda!

Congrats on creating your first serverless application 🎉

To learn more about deployments, head over the Deployment guide.


In case your application is showing a blank page after being deployed, have a look at the logs.

Website assets

Have a look at the Website guide to learn how to deploy a website with assets.