Runtimes
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 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
The name of the runtimes follow this pattern:
arn:aws:lambda:<region>:209497400698:layer:<layer-name>:<layer-version>
Region (<region>
)
The <region>
placeholder should contain your application's region. You need to use the same region as the rest of your application else Lambda will not find the layer.
Runtime (<layer-name>
)
php-73
/php-72
: contains the PHP binary, for non-HTTP applicationsphp-73-fpm
/php-72-fpm
: contains PHP-FPM for HTTP applicationsconsole
: layer that should be used on top ofphp-72
/php-73
to run console commandsphp-72-loop
: experimental mode, not documented yet
Bref currently provides runtimes for PHP 7.2 and 7.3.
php-73
means PHP 7.3.*. It is not possible to require a specific "patch" version.
Layer version (<layer-version>
)
The list of runtime versions is hosted at runtimes.bref.sh and is shown below:
Usage
To use a runtime you need to import the corresponding layer into your Lambda. For example using AWS SAM:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
DemoFunction:
Type: AWS::Serverless::Function
Runtime: provided
Properties:
[...]
Layers:
- '<the layer ARN here>'
You can read more about this in the next sections.