Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I am just a beginner to AWS. I need to know about lambda support. I am working on PHP.

Is the lambda supports PHP? If not is there any other alternative solution for it which supports PHP?

2 Answers

0 votes
by (44.4k points)

Currently, Lambda supports only these languages - Node.js, Python, Java, Ruby, C#, Go and PowerShell. Maybe in the future. 

To run PHP you will have to do a little extra work. Check this documentation on Scripting Languages for AWS Lambda: Running PHP. This is a little old because now GO and Ruby is supported.

 

0 votes
by (300 points)
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

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...