The basics of using SAM Cli for AWS Lambda PHP applications.
- Install SAM Cli by following the Quick Start
- Set up your AWS credentials
- Select one under the options
- Create php binary by following steps in
doc/create_php_binary.md
- Use prebuilt Php 7.3.1
- Just put the yml this projects ARN
arn:aws:lambda:eu-central-1:303814004728:layer:aws-lambda-layer-php-7-3-1:3
- Create php binary by following steps in
- Write your serverless application (!) - the default is in
src/handlers/hello.php
- Run
./deploy.sh
to deploy to Lambda
Handler: filename.functionName hello.hello The signature for the PHP function is:
function main($eventData) : array
Hello world looks like:
<?php
function hello($eventData) : array
{
return ["msg" => "Hello from PHP " . PHP_VERSION];
}