Setup

You can deploy PHP applications with Bref using either:

Bref Cloud is the easiest way to deploy PHP applications. It simplifies setting up and managing AWS credentials, and it provides a dashboard to manage your applications, view logs, and more. Learn more about Bref Cloud.

This page will help you set up your environment for either option.

Before getting started, you will need PHP (8.2 or greater) and NPM installed.

Bref Cloud

To use Bref Cloud, you will need a Bref Cloud account, an AWS account, and the bref CLI. Let’s get started:

Bref Cloud account

First, visit bref.cloud to create an account.

AWS account

Bref Cloud deploys your applications to your AWS account.

To create an AWS account, go to aws.amazon.com and click Sign up. Bref Cloud will guide you through the process of creating an AWS account and connecting it to Bref Cloud.

If you want to learn more about how Bref Cloud connects securely to your AWS account, read the “Security” documentation.

AWS has a generous free tier that will usually allow you to deploy your first serverless applications for free.

Bref CLI

Next, let’s install the Bref CLI:

composer global require bref/cli

Finally, let’s connect the CLI to your Bref Cloud account:

bref login

If the bref command is not found, or if you want more details on how to install the CLI, read the detailed installation instructions.

That’s it, you’re ready to use Bref with Bref Cloud!

Serverless CLI

If you don’t want to use Bref Cloud, you can deploy PHP applications using the open-source Serverless CLI.

To use Bref with the Serverless CLI, you will need an AWS account, the serverless CLI, and AWS credentials. Let’s get started:

AWS account

Bref deploys your applications to your AWS account. To create one, go to aws.amazon.com and click Sign up.

AWS has a generous free tier that will usually allow you to deploy your first serverless applications for free.

Serverless CLI

Bref relies on the Serverless Framework and AWS access keys to deploy applications. You will need to install the serverless CLI using NPM:

npm install -g osls

The original Serverless Framework is no longer open-source. An open-source alternative is OSS Serverless, created and maintained by Bref maintainers. This is a drop-in replacement for the original CLI and is used throughout this documentation.

AWS credentials

Finally, we need AWS credentials so that the serverless CLI can deploy to AWS.

If you have already set up AWS credentials on your machine (for example if you use the aws CLI), you can skip this step.

  • Create AWS access keys

  • Set up those keys by running:

    serverless config credentials --provider aws --key "key" --secret "secret"

    This will store the credentials in ~/.aws/credentials (the official file for AWS credentials). This is the same as running the aws configure command with the aws CLI.

    Alternatively (for example in CI/CD), you can store credentials in environment variables:

    export AWS_ACCESS_KEY_ID=key
    export AWS_SECRET_ACCESS_KEY=secret

That’s it, you’re ready to use Bref with the Serverless CLI!

Bref is compatible with PHP 8.2 or greater. If you are using PHP 8.0 or 8.1, Bref v2 (previous major version) will be installed instead.