How to Update Bref PHP Version for AWS Lambda Runtime Environments

Bref is a framework for building serverless PHP applications on AWS Lambda. The PHP runtime on AWS Lambda is managed by AWS, and you cannot directly update the PHP version yourself. AWS Lambda periodically updates its supported runtime versions, but it may not always have the latest PHP version available.

Where Can I Find the Latest Supported PHP Version for AWS Lambda

You can find the latest version of Bref PHP runtimes at the given URL https://runtimes.bref.sh/

Is there a way to orchestrate the version of PHP using Bref?

No.

Why can’t we do this in Bref itself to control Lambda?

  • Bref isn’t like the Serverless Framework where you can deploy the Infrastructure as Code along with your serverless function.

Manual steps to update the PHP version for AWS Lambda’s using Bref

  1. Create a new layer with the desired PHP version in your AWS Lambda.

  2. Once the layer is successfully created, update the Layers and Runtime value in serverless.yml

  3. Set the Runtime value to provided.al2 (is the generic Linux environment for custom runtimes)

  4. Follow below steps to add a new layer.

    1. Go to your Lambda function.

    2. Click on Add a layer

    3. Choose Specify an ARN

    4. Select an ARN for desired PHP version available at Bref runtime versions and click Verify button.

      Make sure you choose ARN for the correct AWS Region, else you will get permissions related errors.
    5. If there is no error and ARN is verified, click Add and new layer will be listed under Layers as show in the screenshot.

  5. Update the PHP version in composer.json

  6. You will also need to update the project dependencies to be compatible with the new PHP version installed.

Lastly, thoroughly test your application to ensure that it works as expected with the updated PHP version and Bref runtime. If you’re set up with a multi-region workflow for staging and deploying your lambdas, then you should be able to test and validate with one region before switching over production.

Closing thoughts about Bref

Serverless means using cloud services that manage the servers for us thereby providing more scalable, affordable and reliable architectures for less effort.

Bref aims to make running PHP applications simple by leveraging serverless technologies. What makes us choose Bref over other serverless frameworks is its tight integration and specialized focused on PHP serverless ecosystem and seamless integration with other AWS services.

Bref has an active community constantly working on improving the Bref PHP library to keep it up to date with the latest PHP updates. Also Bref provides a well-maintained documentation, resources and support to the developer adopting serverless PHP on AWS Lambda