An open API service indexing awesome lists of open source software.

https://github.com/thbley/php-lambda

Getting started with PHP on AWS Lambda
https://github.com/thbley/php-lambda

Last synced: about 1 year ago
JSON representation

Getting started with PHP on AWS Lambda

Awesome Lists containing this project

README

          

## Getting started with PHP on AWS Lambda

```
docker build -t lambda-php-runtime .

docker run --rm --entrypoint /opt/bin/php lambda-php-runtime -v
docker run --rm --entrypoint /opt/bin/php lambda-php-runtime -m
docker run --rm --entrypoint /opt/bin/php lambda-php-runtime -r 'echo 0.7+0.1;'
docker run --rm --entrypoint /opt/bin/php lambda-php-runtime -r 'echo json_encode(0.7+0.1);'

docker run --rm --entrypoint bash lambda-php-runtime -c "cat /opt/bin/php" >bin/php

docker run --rm -v "$PWD":/var/task lambda-php-runtime hello '{"Hello": "bephpug"}'

zip -r runtime.zip bootstrap bin
zip -r vendor.zip vendor/

aws iam create-role \
--role-name LambdaPhp --path "/service-role/" \
--assume-role-policy-document file://trust-policy.json

aws lambda publish-layer-version \
--layer-name php-runtime --region eu-central-1 \
--zip-file fileb://runtime.zip

aws lambda publish-layer-version \
--layer-name php-vendor --region eu-central-1 \
--zip-file fileb://vendor.zip

zip hello.zip src/hello.php

aws lambda create-function --function-name php-hello --handler hello \
--runtime provided --region eu-central-1 \
--zip-file fileb://hello.zip \
--role "arn:aws:iam::" \
--layers "arn:aws:lambda:" \
"arn:aws:lambda: