Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does AWS Lambda supports PHP? [closed]

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?

like image 401
sheetal dhumal Avatar asked May 22 '17 10:05

sheetal dhumal


People also ask

Does AWS Lambda support 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.

What is AWS Lambda not good for?

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.

Can PHP run serverless?

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.

Is AWS Lambda always running?

Lambda has a hard timeout of 15 minutes. Therefore it cannot run continuously.


4 Answers

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

like image 171
Paulo Victor Avatar answered Oct 21 '22 03:10

Paulo Victor


Natively AWS Lambda supports only following languages as of May 22, 2017

  1. C#
  2. Edge Node.js 4.3
  3. Java 8
  4. Node,js 4.3
  5. Node.js 6.10
  6. Python 2.7
  7. Python 3.6

However if you want, you can tweak it a bit to use PHP as outlined here

like image 28
Arafat Nalkhande Avatar answered Oct 21 '22 03:10

Arafat Nalkhande


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

like image 26
Colwin Avatar answered Oct 21 '22 04:10

Colwin


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/

like image 20
javee Avatar answered Oct 21 '22 03:10

javee