AWS Lambda is powered by Docker containers. If you provide a script, Lambda will download the script and execute it within a Docker container. If you provide a zip file, Lambda will download the zip and execute the contents within a Docker contianer.
The docker containers Lambda runs are Amazon Linux. Amazon Lambda does not natively support php, however we can use php if we compile a static single-binary version which can be called by another language that Lambda does support, like NodeJS.
var args = ['handler.php', JSON.stringify(event), JSON.stringify(contextData)];
var options = {stdio: ['pipe', 'pipe', 'pipe', 'pipe']};
var proc = child_process.spawn("./php", args, options);
How to compile php 5.6.6 for Lambda
There is an Amazon Linux docker container available. We will download the docker container and use that to compile our php binary.
docker pull amazonlinux:2016.09