AWS SAM PHP

Automates a serverless PHP Lambda implementation ready production, including CI/CD.

The PHP Lambda function generates a JSON response {"status":"OK."}.

Showcase code

When & Why

Use this as a template to quickstart a serverless PHP based service.

Implementation Details

Use Bref Runtimes Layers, for running PHP on Lambda.

template.yaml view raw
Type: AWS::Serverless::Function
Properties:
  CodeUri: src/
  Layers: ["arn:aws:lambda:eu-west-1:209497400698:layer:php-80:9"]
  Handler: main.php

Composer

  • bref/bref composer package is required to create communication between the PHP and the Lambda API.
  • composer.json & composer.lock should be added on the same level as the entry php file.
  • Finally composer install should be run before deploying the infrastructure.