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?
Since there's no native support for PHP in Lambda, we'll need to provide the PHP binary for Lambda to use so that we acn execute our custom runtime code.
You do not want to use Lambda for long-running workloads because it runs instances/functions for up to 15 minutes at a time. It limits concurrent function executions to 1,000. AWS Lambda bills can quickly run through your budget if you are unsure how to optimize AWS costs.
running PHP made simple By using serverless technologies, like AWS Lambda, we can focus on development and worry less about servers. Bref is an open source project that brings full support for PHP and its frameworks to AWS Lambda.
Lambda has a hard timeout of 15 minutes. Therefore it cannot run continuously.
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
Natively AWS Lambda supports only following languages as of May 22, 2017
However if you want, you can tweak it a bit to use PHP as outlined here
Yes AWS Lambda does support PHP with a little tweaking. Here are a couple links to get you started.
https://aws.amazon.com/blogs/compute/scripting-languages-for-aws-lambda-running-php-ruby-and-go/
http://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-lambda.html
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With