This repo contains an implementation of PHP runtime layer with AWS Lambda.
Files:
runtime/php
- Statically compiled PHP 7.2.11 on alinux 2017.03runtime/bootstrap
- This is a Bash script. This initizlizes and starts the PHP runtimeruntime/runtime.php
- This contains the interations with AWS runtime API and the main logic to execute the function handlerfunction/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
function.handler
- Create a file
function.php
with a function calledhandler($eventData)
, this function will be called when lambda is invoked.