AWS Lambda Runtime sample - PHP
This repo contains an implementation of PHP runtime layer with AWS Lambda.
runtime/php- Statically compiled PHP 7.2.11 on alinux 2017.03
runtime/bootstrap- This is a Bash script. This initizlizes and starts the PHP runtime
runtime/runtime.php- This contains the interations with AWS runtime API and the main logic to execute the function handler
function/Function.php- Sample lambda function
This runtime expects the function handler in AWS Lambda configuration in the form
filename.handler. This means that if you configure AWS lambda's handler field as
filename.handler the runtime layer will look for a file
fielname.php in your function code and execute the function
handler passing in the event payload as the first argument. Refer to file
function/Function.php in this repositiory for example.
To use this runtime:
- Create a Lambda function from scratch.
- Select custom runtime
- Zip the files bootstrap, static PHP binary and runtime.php
- Create a layer with the zip file created in above step
- Configure the lambda function to have this layer
- Define the handler in lambda function
- Create a file
function.phpwith a function called
handler($eventData), this function will be called when lambda is invoked.