PHP runtimes for AWS Lambda

There is no built-in support for PHP on AWS Lambda. Instead we need to use 3rd party runtimes via the system of Lambda layers.

Bref provides the runtimes (aka layers) needed to run PHP applications, whether they run via functions, HTTP or CLI.

This page is an introduction to the runtimes. The next sections (e.g. PHP functions, HTTP applications) will show how to use them in your project.

Bref runtimes

PHP functions: php-74 and php-73

The simplest way to write a lambda is to write one in the form of a PHP function.

This runtime works great for non-HTTP applications.

Read more about the php-74 runtime here.

HTTP applications: php-74-fpm and php-73-fpm

This runtime uses PHP-FPM to run HTTP applications on AWS Lambda.

This runtime is the easiest to start with: it works like traditional PHP hosting and is compatible with Symfony and Laravel.

Read more about the php-74-fpm runtime here.

Console: console

This runtime lets use run console commands on Lambda.

For example we can run the Symfony Console or Laravel Artisan.

Read more about the console runtime here.


To use a runtime, import the corresponding layer in serverless.yml:

service: app
    name: aws
    runtime: provided
    - ./vendor/bref/bref
            - ${bref:layer.php-73}

The ${...} notation is the syntax to use variables in serverless.yml. Bref provides a serverless plugin ("./vendor/bref/bref") that provides those variables:

  • ${bref:layer.php-74}
  • ${bref:layer.php-73}
  • ${bref:layer.php-72}
  • ${bref:layer.php-74-fpm}
  • ${bref:layer.php-73-fpm}
  • ${bref:layer.php-72-fpm}
  • ${bref:layer.console}

Bref currently provides runtimes for PHP 7.2, 7.3 and 7.4.

php-74 means PHP 7.4.*. It is not possible to require a specific "patch" version.

You can read more about this in the next sections.

Lambda layers in details

Notice: this section is only useful if you want to learn more.

You can skip it for now if you just want to get started with Bref.

Bref runtimes are AWS Lambda layers. While Bref provides a Serverless plugin to simplify how to use them, you can use the layers directly.

The name of the layers follow this pattern:


To use them manually you need to use that full name. For example in serverless.yml:

service: app
    name: aws
    runtime: provided
            - 'arn:aws:lambda:us-east-1:209497400698:layer:php-73:7'

Or if you are using SAM's template.yaml:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
        Type: AWS::Serverless::Function
            Runtime: provided
                - 'arn:aws:lambda:us-east-1:209497400698:layer:php-73:7'

Remember: the layer ARN contains a region. You need to use the same region as the rest of your application else Lambda will not find the layer.

Layer version (<layer-version>)

The latest of runtime versions can be found at and is shown below: