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?
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?
Actually no, but since November of 2018 AWS announced the Lambda layer which is basically the way to you run your own runtime such as PHP. You have two simple ways to run lambda with PHP
1 - Create your own cloudformation stack passing the PHP layer for example arn:aws:lambda:us-east-1:887080169480:layer:php73:2
Something like that template.yml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: ''
Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: 'php-layer'
Description: ''
CodeUri: .
Handler: index.php
Timeout: 10 # Timeout in seconds
MemorySize: 1024 # The memory size is related to the pricing and CPU power
Runtime: provided
Layers:
- 'arn:aws:lambda:us-east-1:887080169480:layer:php73:2'
And create a PHP file index.php
<?php
echo "Hello from PHP Experience 2019";
?>
Create an AWS s3 bucket (for example mybuckettest)
Packaged cloudformation stack
sam package \
--template-file template.yml \
--output-template-file serverless-output.yaml \
--s3-bucket phpex
Deploy your stack
sam deploy \
--template-file serverless-output.yaml \
--stack-name php-layer \
--capabilities CAPABILITY_IAM
done
2 - Use the bref.sh a very simple PHP framework for aws lambda
As from the latest update!!, AWS Almbda Does Support PHP now.
Source : https://aws.amazon.com/blogs/compute/scripting-languages-for-aws-lambda-running-php-ruby-and-go/
When you work with AWS Lambda, you may also want to work with serverless package as it makes ongoing deployment and code management easier. you can check my implementation of serverless-php-lambda based on running amazon-linux vm and getting all php binaries from there. this allows to configure php more easier, no compilation, with libraries such as redis etc.