First steps

This guide will help you deploy your first PHP application on AWS Lambda. For simplicity, we will not be using a PHP framework yet.

Before getting started make sure you have installed Bref and the required tools first.

Initializing the project

Starting 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 the 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 the code in index.php, but for now let's keep it simple: we want to run index.php on Lambda first.


To deploy, let's 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.

What's next?

Now that you have deployed a simple PHP web app, you can learn more about runtimes. That will help you deploy HTTP and console applications.